On Sep 28, 2012, at 1:16 PM, JiangZhengyu wrote: > > Hi guys, I have many rows (>1000) and columns (>30) of "geno" matrix. I use > the following loop and condition statement (adapted from someone else code). > I always have an error below. I was wondering if anyone knows what's the > problem & how to fix it.
Boy, it surely looks like missing values are the problem. Have you read: ?sum -- David. > Thanks,Zhengyu ########### geno matrix P1 P2 P3 P4 > 1 2 2 3 2 > 2 2 2 1 1 > 1 2 1 2 NANA 2 3 4 5 ########### > for(i in 1:4) { > cat(i,"") > if(sum(geno[i,]!=2)>3 && sum(geno[i,]==1)>=1 && sum(geno[i,]==3)>=1){ > tmp = 1 > } > } ########### 1 2 Error in if (sum(geno[i, ] != 2) > 3 && sum(geno[i, ] == 1) > >= 1 && sum(geno[i, : > missing value where TRUE/FALSE needed > > [[alternative HTML version deleted]] David Winsemius, MD Alameda, CA, USA ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.