[adegenet-commits] r79 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Mar 27 17:30:32 CET 2008


Author: jombart
Date: 2008-03-27 17:30:32 +0100 (Thu, 27 Mar 2008)
New Revision: 79

Modified:
   pkg/R/classes.R
Log:
Fixes for old2new (pop missing was causing an error).


Modified: pkg/R/classes.R
===================================================================
--- pkg/R/classes.R	2008-03-27 13:16:42 UTC (rev 78)
+++ pkg/R/classes.R	2008-03-27 16:30:32 UTC (rev 79)
@@ -742,18 +742,25 @@
 setMethod("old2new", "genind", function(object){
   x <- object
   res <- new("genind")
-
+  theoLength <- 7
+  
   res at tab <- as.matrix(x$tab)
   res at ind.names <- as.character(x$ind.names)
   res at loc.names <- as.character(x$loc.names)
   res at loc.nall <- as.integer(x$loc.nall)
   res at loc.fac <- as.factor(x$loc.fac)
   res at all.names <- as.list(x$all.names)
-  res at pop <- as.factor(x$pop)
-  res at pop.names <- as.character(x$pop.names)
+  if(!is.null(x$pop)) {
+      res at pop <- as.factor(x$pop)
+      theoLength <- theoLength + 1
+  }
+  if(!is.null(x$pop.names)) {
+      res at pop.names <- as.character(x$pop.names)
+      theoLength <- theoLength + 1
+  }
   res at call <- match.call()
 
-  if(length(object)>9) warning("optional content else than pop and pop.names was not converted")
+  if(length(object) > theoLength) warning("optional content else than pop and pop.names was not converted")
 
   return(res)
 })



More information about the adegenet-commits mailing list