[Phylobase-commits] r156 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Mar 8 02:39:36 CET 2008
Author: pdc
Date: 2008-03-08 02:39:36 +0100 (Sat, 08 Mar 2008)
New Revision: 156
Modified:
pkg/R/methods-phylo4.R
pkg/R/phylo4.R
Log:
Move a couple last methods
Modified: pkg/R/methods-phylo4.R
===================================================================
--- pkg/R/methods-phylo4.R 2008-03-08 01:16:11 UTC (rev 155)
+++ pkg/R/methods-phylo4.R 2008-03-08 01:39:36 UTC (rev 156)
@@ -1,3 +1,10 @@
+## accessor functions for all internal bits
+## HORRIBLE KLUGE
+nTips <- function(x,...) { } ## mask ape::nTips
+setGeneric("nTips", function(x,...) {
+ standardGeneric("nTips")
+})
+
setMethod("nTips", "phylo4", function(x, ...) {
E <- edges(x)
res <- sum(!E[, 2] %in% E[, 1])
@@ -4,6 +11,15 @@
return(res)
})
+## hack to ensure ape compatibility
+setMethod("nTips","ANY", function(x) {
+ if (class(x)=="phylo") {
+ Ntip(x)
+ } else stop(paste("no 'nTips' method available for",
+ deparse(substitute(x)),
+ "(class",class(x),")"))
+})
+
setMethod("nNodes", "phylo4", function(x) {
x at Nnode
})
@@ -100,6 +116,12 @@
return(x)
})
+
+printphylo4 <- function(x, printall = TRUE){
+ if (printall)
+ print(as(x, 'data.frame'))
+ else print(head(as(x, 'data.frame')))
+}
## hack for print/show
## from http://tolstoy.newcastle.edu.au/R/e2/devel/06/12/1363.html
#setMethod("print", "phylo4", printphylo)
@@ -110,12 +132,6 @@
# Alternative print method for phylo4, showing the contents of the tree data.
## Not sure if it works for unrooted trees
-printphylo4 <- function(x, printall = TRUE){
- if (printall)
- print(as(x, 'data.frame'))
- else print(head(as(x, 'data.frame')))
-}
-
printphylo <- function (x,printlen=6,...) {
printlen <- max(1,printlen)
nb.tip <- length(x$tip.label)
Modified: pkg/R/phylo4.R
===================================================================
--- pkg/R/phylo4.R 2008-03-08 01:16:11 UTC (rev 155)
+++ pkg/R/phylo4.R 2008-03-08 01:39:36 UTC (rev 156)
@@ -1,22 +1,6 @@
require(methods)
require(ape)
-
-## accessor functions for all internal bits
-## HORRIBLE KLUGE
-nTips <- function(x,...) { } ## mask ape::nTips
-setGeneric("nTips", function(x,...) {
- standardGeneric("nTips")
-})
-## hack to ensure ape compatibility
-setMethod("nTips","ANY", function(x) {
- if (class(x)=="phylo") {
- Ntip(x)
- } else stop(paste("no 'nTips' method available for",
- deparse(substitute(x)),
- "(class",class(x),")"))
-})
-
setGeneric("nNodes", function(x) {
standardGeneric("nNodes")
})
More information about the Phylobase-commits
mailing list