[adegenet-commits] r369 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jun 5 13:45:34 CEST 2009


Author: jombart
Date: 2009-06-05 13:45:34 +0200 (Fri, 05 Jun 2009)
New Revision: 369

Modified:
   pkg/R/haploSim.R
Log:
Added useful functions to treat haploSim objects:
[ operator
na.omit


Modified: pkg/R/haploSim.R
===================================================================
--- pkg/R/haploSim.R	2009-06-04 20:30:57 UTC (rev 368)
+++ pkg/R/haploSim.R	2009-06-05 11:45:34 UTC (rev 369)
@@ -298,3 +298,35 @@
 
     return(NULL)
 } # end print.haploSim
+
+
+
+
+##############
+## [.haploSim
+##############
+"[.haploSim" <- function(x,i,j,drop=FALSE){
+    res <- x
+    res$seq <- res$seq[i,]
+    res$ances <- res$ances[i]
+    res$dates <- res$dates[i]
+    if(!is.null(res$xy)) res$xy <- res$xy[i,]
+
+    return(res)
+}
+
+
+
+####################
+## na.omit.haploSim
+####################
+na.omit.haploSim <- function(object, ...){
+    res <- object
+    isNA <- is.na(res$ances)
+    res$seq <- res$seq[!isNA,]
+    res$ances <- res$ances[!isNA]
+    res$dates <- res$dates[!isNA]
+    if(!is.null(res$xy)) res$xy <- res$xy[!isNA,]
+
+    return(res)
+}



More information about the adegenet-commits mailing list