[R] counting columns that fulfill specific criteria
pguilha
paul.guilhamon at gmail.com
Fri Jun 24 13:14:57 CEST 2011
Hi,
I have a matrix (pwdiff in the example below) with ~480000 rows and 780
columns.
For each row, I want to get the percentage of columns that have an absolute
value above a certain threshold "t". I then want to allocate that percentage
to matrix 'perc' in the corresponding row. Below is my attempt at doing
this, but it does not work: I get 'replacement has length zero'. Any help
would be much appreciated!!
perc<-matrix(c(1:nrow(pwdiff)))
for (x in 1:nrow(pwdiff))
perc[x]<-(((ncol(pwdiff[,abs(pwdiff[x,]>=t)]))/ncol(pwdiff))*100)
I should add that my data has NAs in some rows and not others (but I do not
want to just ignore rows that have NAs)
Thanks!
Paul
--
View this message in context: http://r.789695.n4.nabble.com/counting-columns-that-fulfill-specific-criteria-tp3622265p3622265.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list