]> git.donarmstrong.com Git - ape.git/blobdiff - R/DNA.R
new as.list.DNAbin
[ape.git] / R / DNA.R
diff --git a/R/DNA.R b/R/DNA.R
index dea2d60ddffbb907e575fa2596de76b83ab7ef48..8b016caad40dc9acb8014c4889bee52fa38c2bf0 100644 (file)
--- a/R/DNA.R
+++ b/R/DNA.R
@@ -1,4 +1,4 @@
-## DNA.R (2010-05-17)
+## DNA.R (2010-07-13)
 
 ##   Manipulations and Comparisons of DNA Sequences
 
@@ -91,6 +91,20 @@ as.matrix.DNAbin <- function(x, ...)
     x
 }
 
+as.list.DNAbin <- function(x, ...)
+{
+    if (is.list(x)) return(x)
+    if (is.vector(x)) obj <- list(x)
+    else { # matrix
+        n <- nrow(x)
+        obj <- vector("list", n)
+        for (i in 1:n) obj[[i]] <- x[i, ]
+        names(obj) <- rownames(x)
+    }
+    class(obj) <- "DNAbin"
+    obj
+}
+
 rbind.DNAbin <- function(...)
 ### works only with matrices for the moment
 {