[adegenet-commits] r386 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 9 14:12:45 CEST 2009


Author: jombart
Date: 2009-06-09 14:12:44 +0200 (Tue, 09 Jun 2009)
New Revision: 386

Modified:
   pkg/R/seqTrack.R
Log:
small tweak to the output of optimize.seqTrack (ances.date)


Modified: pkg/R/seqTrack.R
===================================================================
--- pkg/R/seqTrack.R	2009-06-09 09:27:25 UTC (rev 385)
+++ pkg/R/seqTrack.R	2009-06-09 12:12:44 UTC (rev 386)
@@ -603,7 +603,7 @@
     ances <- data.frame(lapply(res, function(e) e$ances))
     ances <- matrix(as.integer(unlist(ances)), nrow=nrow(ances))
 
-    ances.date <- data.frame(lapply(res, function(e) e$ances.date))
+    ances.date <- data.frame(lapply(res, function(e) as.character(e$ances.date)))
     ances.date <- matrix(as.character(unlist(ances.date)), nrow=nrow(ances.date))
 
 
@@ -620,19 +620,26 @@
 #################
 ## get.result.by
 #################
-get.result.by <- function(x, bydat){
-    dat <- bydat
+get.result.by <- function(x, ...){
+    dat <- list(...)
+    if(length(dat)==0) return(x)
 
-    ## define new values
-    if(class(dat)=="DNAbin"){
-        if(!is.matrix(dat)) dat <- as.matrix(dat)
-        dat <- as.character(dat)
+
+    ## DEFINE NEW VALUES ##
+
+    convertElem <- function(e){
+        if(class(e)=="DNAbin") {
+            e <- as.matrix(e)
+        }
+        ori.dim <- dim(e)
+        e <- as.character(e)
+        dim(e) <- ori.dim
     }
 
-    ori.dim <- dim(dat)
-    dat <- as.character(bydat)
-    dim(dat) <- ori.dim
 
+    dat <- lapply(dat,convertElem)
+    dat <- as.matrix(data.frame(dat))
+
     newval <- apply(dat, 1, function(vec) paste(vec, collapse=""))
     newval <- unclass(factor(newval))
     newlev <- levels(newval)



More information about the adegenet-commits mailing list