How to create a loop in R to count coincidences in a table? -


i need help, have table in r may columns, lets interested in columns v111 v135 , count rows in each column different './.'.

i can each column independently (it says me number of coincidences different ./.)

m <-p[p$v111 != './.', ] 

but appreciate suggest me loop number of coincidences each column.

v110    v111    v112 ./. 1/1:0,51:51:99:2136,153,0   1/1:0,28:28:84:1211,84,0 ./. ./. 0/1:15,13:28:99:434,0,543 ./. ./. ./. ./. ./. ./. ./. ./. ./. 1/1:0,21:21:63:875,63,0 ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. 1/1:0,18:18:54:745,54,0 1/1:0,5:5:15:207,15,0 ./. 1/1:0,2:2:6:90,6,0  ./. ./. 1/1:0,2:2:6:90,6,0  ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. 0/1:6,4:10:99:137,0,210 ./. 

you count number of rows without './.' in each column colsums(). data provided, if wanted count rows without './.' in first 2 columns, you'd do

colsums(p[,1:2] != "./.") #v110 v111  #   1    5  

if wanted rows in each column there no './.', you'd do

lapply(p[,1:2], function(x) which(x != "./.")) #$v110 #[1] 6  #$v111 #[1]  1 12 13 14 18 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -