[Picante-commits] r60 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Apr 26 01:47:58 CEST 2008
Author: skembel
Date: 2008-04-26 01:47:58 +0200 (Sat, 26 Apr 2008)
New Revision: 60
Added:
pkg/R/phylocom.R
Removed:
pkg/R/readsample.R
pkg/R/sample2matrix.R
pkg/R/writesample.R
pkg/R/writetraits.R
Log:
Combine phylocom data read/write functions into a single file
Added: pkg/R/phylocom.R
===================================================================
--- pkg/R/phylocom.R (rev 0)
+++ pkg/R/phylocom.R 2008-04-25 23:47:58 UTC (rev 60)
@@ -0,0 +1,45 @@
+`sample2matrix` <-
+function(x) {
+
+#turns a phylocom-format sample file into a sample X species matrix
+#assumes a phylocom-format sample:
+#no header line data
+#column 1 = plot, column 2 = abundance, column 3 = species
+#to load a phylocom-format file directly, try:
+#sample2matrix(read.delim2(file="FILENAME",header=F))
+ colnames(x) <- c("plot","abund","id")
+ y <- tapply(x$abund, list(x$plot, x$id), sum)
+ y[is.na(y)] <- 0
+ y
+}
+
+
+`readsample` <-
+function (filename = "") {
+ x <- read.table(file = filename, header = FALSE, sep = "\t", col.names = c("plot",
+ "abund", "id"))
+ sample2matrix(x)
+}
+
+
+`writesample` <-
+function (community, filename = "") {
+ write.table(matrix2sample(community), file = filename, append = FALSE,
+ sep = "\t", eol = "\n", quote = FALSE, row.names = FALSE, col.names = FALSE)
+}
+
+
+`writetraits` <-
+function (trt, file = "", bin = NULL, sigd = 3)
+{
+ head = matrix(c("3"), ncol = length(names(trt)), nrow = 1)
+ if (!is.null(bin))
+ head[bin] = 0
+ write.table(data.frame("type", head), file = file, sep = "\t",
+ quote = FALSE, row.names = FALSE, col.names = FALSE)
+ write.table(matrix(c("name", colnames(trt)), nrow = 1),
+ file = file, sep = "\t", append = TRUE, quote = FALSE,
+ row.names = FALSE, col.names = FALSE)
+ write.table(signif(trt, sigd), sep = "\t", file = file, append = TRUE, quote = FALSE,
+ row.names = TRUE, col.names = FALSE)
+}
Deleted: pkg/R/readsample.R
===================================================================
--- pkg/R/readsample.R 2008-04-25 23:42:55 UTC (rev 59)
+++ pkg/R/readsample.R 2008-04-25 23:47:58 UTC (rev 60)
@@ -1,7 +0,0 @@
-`readsample` <-
-function (filename = "") {
- x <- read.table(file = filename, header = FALSE, sep = "\t", col.names = c("plot",
- "abund", "id"))
- sample2matrix(x)
-}
-
Deleted: pkg/R/sample2matrix.R
===================================================================
--- pkg/R/sample2matrix.R 2008-04-25 23:42:55 UTC (rev 59)
+++ pkg/R/sample2matrix.R 2008-04-25 23:47:58 UTC (rev 60)
@@ -1,15 +0,0 @@
-`sample2matrix` <-
-function(x) {
-
-#turns a phylocom-format sample file into a sample X species matrix
-#assumes a phylocom-format sample:
-#no header line data
-#column 1 = plot, column 2 = abundance, column 3 = species
-#to load a phylocom-format file directly, try:
-#sample2matrix(read.delim2(file="FILENAME",header=F))
- colnames(x) <- c("plot","abund","id")
- y <- tapply(x$abund, list(x$plot, x$id), sum)
- y[is.na(y)] <- 0
- y
-}
-
Deleted: pkg/R/writesample.R
===================================================================
--- pkg/R/writesample.R 2008-04-25 23:42:55 UTC (rev 59)
+++ pkg/R/writesample.R 2008-04-25 23:47:58 UTC (rev 60)
@@ -1,6 +0,0 @@
-`writesample` <-
-function (community, filename = "") {
- write.table(matrix2sample(community), file = filename, append = FALSE,
- sep = "\t", eol = "\n", quote = FALSE, row.names = FALSE, col.names = FALSE)
-}
-
Deleted: pkg/R/writetraits.R
===================================================================
--- pkg/R/writetraits.R 2008-04-25 23:42:55 UTC (rev 59)
+++ pkg/R/writetraits.R 2008-04-25 23:47:58 UTC (rev 60)
@@ -1,15 +0,0 @@
-`writetraits` <-
-function (trt, file = "", bin = NULL, sigd = 3)
-{
- head = matrix(c("3"), ncol = length(names(trt)), nrow = 1)
- if (!is.null(bin))
- head[bin] = 0
- write.table(data.frame("type", head), file = file, sep = "\t",
- quote = FALSE, row.names = FALSE, col.names = FALSE)
- write.table(matrix(c("name", colnames(trt)), nrow = 1),
- file = file, sep = "\t", append = TRUE, quote = FALSE,
- row.names = FALSE, col.names = FALSE)
- write.table(signif(trt, sigd), sep = "\t", file = file, append = TRUE, quote = FALSE,
- row.names = TRUE, col.names = FALSE)
-}
-
More information about the Picante-commits
mailing list