[adegenet-commits] r767 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 18 17:16:31 CET 2011


Author: jombart
Date: 2011-01-18 17:16:30 +0100 (Tue, 18 Jan 2011)
New Revision: 767

Modified:
   pkg/R/SNPbin.R
Log:
Conversions are now effective in C both ways.


Modified: pkg/R/SNPbin.R
===================================================================
--- pkg/R/SNPbin.R	2011-01-18 13:04:32 UTC (rev 766)
+++ pkg/R/SNPbin.R	2011-01-18 16:16:30 UTC (rev 767)
@@ -587,9 +587,7 @@
 ###########
 ## convert vector of raw to 0/1 integers
 .raw2bin <- function(x){
-    if(!is.integer(x)) {
-        x <- as.integer(x)
-    }
+    if(!is.raw(x)) stop("x is not of class raw")
     ## SNPCOMB <- as.matrix(expand.grid(rep(list(c(0,1)), 8)))
     ## colnames(SNPCOMB) <- NULL
     ## res <- unlist(lapply(as.integer(x), function(i) SNPCOMB[i+1,]))
@@ -689,7 +687,11 @@
 ##
 ##
 ## library(adegenet)
+dat <- c(1,0,0,1,0,NA,1,0,0,0,0,1)
+x <- new("SNPbin",dat)
+as.integer(x)
 
+
 ## HAPLOID DATA - NO NA
 ## dat <- sample(c(0L,1L), 1e6, replace=TRUE)
 ## x <- new("SNPbin", dat)
@@ -734,7 +736,12 @@
 ##
 
 
-## SIMPLE TEST
+## SIMPLE TESTS
+dat <- c(1,0,0,1,0,0,1,1,1,0,1)
+x <- new("SNPbin",dat)$snp[[1]]
+as.integer(x)==dat
+
+
 ## library(adegenet)
 ## dat <- list(toto=c(1,1,0,0), titi=c(NA,1,1,0), tata=c(NA,0,3, NA))
 ## x <- new("genlight", dat)



More information about the adegenet-commits mailing list