[Ecopd-commits] r69 - in branches/single-tree: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Nov 14 02:22:47 CET 2009


Author: regetz
Date: 2009-11-14 02:22:46 +0100 (Sat, 14 Nov 2009)
New Revision: 69

Modified:
   branches/single-tree/R/utilities.R
   branches/single-tree/man/abundance.Rd
Log:
fixed codoc mismatches for abundance and presence functions


Modified: branches/single-tree/R/utilities.R
===================================================================
--- branches/single-tree/R/utilities.R	2009-11-14 01:14:56 UTC (rev 68)
+++ branches/single-tree/R/utilities.R	2009-11-14 01:22:46 UTC (rev 69)
@@ -45,7 +45,7 @@
 }
 
 # abundance extractor
-abundance <- function(phy, comm, tip) {
+abundance <- function(phy, comm, tip, na.zero=FALSE) {
     communities <- names(phy at metadata$comms)
     if (missing(comm)) {
         comm <- communities
@@ -61,7 +61,9 @@
         tip <- getNode(phy, tip, type="tip", missing="warn")
         tip <- names(tip)[!is.na(tip)]
     }
-    return(tipData(phy)[tip, comm, drop=FALSE])
+    N <- tipData(phy)[tip, comm, drop=FALSE]
+    if (na.zero) N[is.na(N)] <- 0
+    return(N)
 }
 
 # abundance assignment function
@@ -81,10 +83,9 @@
 }
 
 presence <- function(phy, comm, tip, na.zero=FALSE) {
-    N <- abundance(phy, comm, tip)
+    N <- abundance(phy, comm, tip, na.zero=na.zero)
     N[N > 0] <- 1
     N[N <= 0] <- 0
-    if (na.zero) N[is.na(N)] <- 0
     N
 }
 

Modified: branches/single-tree/man/abundance.Rd
===================================================================
--- branches/single-tree/man/abundance.Rd	2009-11-14 01:14:56 UTC (rev 68)
+++ branches/single-tree/man/abundance.Rd	2009-11-14 01:22:46 UTC (rev 69)
@@ -7,8 +7,8 @@
 tree.
 }
 \usage{
-  abundance(phy, comm, tip, na.zero=TRUE)
-  presence(phy, comm, tip, na.zero=TRUE)
+  abundance(phy, comm, tip, na.zero=FALSE)
+  presence(phy, comm, tip, na.zero=FALSE)
   abundance(phy, comm, tip) <- value
 }
 \arguments{
@@ -51,7 +51,7 @@
 
   ## abundance replacement
   abundance(weeds, "A", "Centaurea_alba") <- NA
-  abundance(weeds, "B", 2:5) <- c(0, 100, 0)
+  abundance(weeds, "B", 2:4) <- c(0, 100, 0)
   abundance(weeds, "C") <- 25
 
   presence(weeds, na.zero=TRUE)



More information about the Ecopd-commits mailing list