[Phylobase-commits] r324 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Dec 19 11:51:53 CET 2008


Author: francois
Date: 2008-12-19 11:51:53 +0100 (Fri, 19 Dec 2008)
New Revision: 324

Modified:
   pkg/R/class-phylo4.R
Log:
node labels is a vector of NA instead of being character(0)

Modified: pkg/R/class-phylo4.R
===================================================================
--- pkg/R/class-phylo4.R	2008-12-19 07:08:42 UTC (rev 323)
+++ pkg/R/class-phylo4.R	2008-12-19 10:51:53 UTC (rev 324)
@@ -1,28 +1,28 @@
-setClass("phylo4", 
-         representation(edge = "matrix", 
-                        edge.length = "numeric", 
-                        Nnode = "integer", 
-                        node.label = "character", 
-                        tip.label = "character", 
-                        edge.label = "character", 
-                        root.edge = "numeric"), 
+setClass("phylo4",
+         representation(edge = "matrix",
+                        edge.length = "numeric",
+                        Nnode = "integer",
+                        node.label = "character",
+                        tip.label = "character",
+                        edge.label = "character",
+                        root.edge = "numeric"),
          prototype = list(
-                        edge = matrix(nrow = 0, ncol = 2, 
-                            dimname = list(NULL, c("ancestor", "descendant"))), 
-                        edge.length = numeric(0), 
-                        Nnode = as.integer(0), 
-                        tip.label = character(0), 
-                        node.label = character(0), 
-                        edge.label = character(0), 
+                        edge = matrix(nrow = 0, ncol = 2,
+                            dimname = list(NULL, c("ancestor", "descendant"))),
+                        edge.length = numeric(0),
+                        Nnode = as.integer(0),
+                        tip.label = character(0),
+                        node.label = character(0),
+                        edge.label = character(0),
                         root.edge = as.numeric(NA)
-                       ), 
+                       ),
          validity = check_phylo4)
 
 #####################
 ## phylo4 constructor
 #####################
 
-phylo4 <- function(edge, edge.length = NULL, tip.label = NULL, node.label = NULL, 
+phylo4 <- function(edge, edge.length = NULL, tip.label = NULL, node.label = NULL,
                    edge.label = NULL, root.edge = NULL, ...){
     ## edge
     mode(edge) <- "integer"
@@ -46,7 +46,7 @@
     } else {
         if(length(tip.label) != ntips) stop("the tip labels are not consistent with the number of tips")
         tip.label <- as.character(tip.label)
-    } 
+    }
 
     ## node.label
     nnodes <- sum(tabulate(edge[, 1]) > 0)
@@ -54,7 +54,8 @@
     ##        node.label <- .genlab("N", nnodes)
     ## } else {
     if(is.null(node.label)) {
-      node.label <- character(0)
+      node.label <- character(nnodes)
+      is.na(node.label) <- TRUE
     } else if (length(node.label) != nnodes)
       stop("the node labels are not consistent with the number of nodes")
     ## edge.label



More information about the Phylobase-commits mailing list