
Dear list,

I am trying to evaluate how many elements in a vector equal a certain value. The vectors are the columns of a data.frame, read in using read.table():

> dim(data)
[1] 2600  742
> data[1:5,1:5]
  SNP001 SNP002 SNP003 SNP004 SNP005
1     GG     AA     TT     TT     GG
2     GG     AA     TC     TT     GG
3     GG     AC     CC     TT     GG
4     AG     AA     TT     TT     GG
5     GG     AA     TC     TT     GG

> table(data[,1])

  AA   AG   GG 
 251 1093 1252 

but if I do

> sum(data[,1]=="GG")
[1] NA

I have tried storing the column it in a vector but with same results:

> yyy<-(data[,1])
> sum(yyy=="GG")
[1] NA

while if I just get a small number of elements from this vector, it works fine
> yyyy <- yyy[1:10]
> yyyy
 [1] "GG" "GG" "GG" "AG" "GG" "GG" "AA" "GG" "AG" "GG"
> table(yyyy)
yyyy
AA AG GG 
 1  2  7 
> sum(yyyy=="GG")
[1] 7

I checked the archives for help but couldn´t find my error
What am I missing?

> sessionInfo()
R version 2.8.1 (2008-12-22) 
i386-pc-mingw32 


attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

Thanks 

Dave


_________________________________________________________________


	[[alternative HTML version deleted]]


