[adegenet-commits] r285 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Apr 1 19:04:03 CEST 2009
Author: jombart
Date: 2009-04-01 19:04:02 +0200 (Wed, 01 Apr 2009)
New Revision: 285
Modified:
pkg/R/propTyped.R
Log:
propTyped ok for genind and PA
Modified: pkg/R/propTyped.R
===================================================================
--- pkg/R/propTyped.R 2009-04-01 16:47:09 UTC (rev 284)
+++ pkg/R/propTyped.R 2009-04-01 17:04:02 UTC (rev 285)
@@ -9,9 +9,32 @@
setMethod("propTyped","genind", function(x, by=c("ind","loc","both")){
- checkType(x)
+ ## checkType(x)
by <- match.arg(by)
+ ## PA case ##
+ if(x at type=="PA"){
+ temp <- as.matrix(x)
+
+ if(by=="ind"){
+ res <- apply(temp,1,function(r) mean(is.na(r)))
+ return(1-res)
+ }
+
+ if(by=="loc"){
+ res <- apply(temp,2,function(r) mean(is.na(r)))
+ return(1-res)
+ }
+
+ if(by=="both"){
+ res <- !is.na(temp)
+ return(res*1)
+ }
+ } # end PA case
+
+
+ ## codom case ##
+
## auxil function f1
f1 <- function(vec){
if(any(is.na(vec))) return(0)
More information about the adegenet-commits
mailing list