Try this:
m[prop.table(rowSums(is.na(m))) < 0.1,]
2010/1/15 Joel Fürstenberg-Hägg :
>
> Hi all,
>
>
>
> I would like to remove rows from a matrix, based on the frequency of missing
> values. If there are more than 10 % missing values, the row should be deleted.
>
>
>
> I use the following to cal
Joel,
try this:
# sample matrix
m <- matrix(sample(c(1:10, NA),150,replace=T),byrow=T,ncol=15)
# nr of missing values per row
nacounts <- apply(m, 1, function(x)length(x[is.na(x)]))
# new matrix
newm <- m[nacounts/ncol(m) < 0.1,]
greetings,
Remko
--
Hi all,
I would like to remove rows from a matrix, based on the frequency of missing
values. If there are more than 10 % missing values, the row should be deleted.
I use the following to calculate the frequencies, thereby getting a new matrix
with the frequencies:
freqNA=rowMeans(is.
3 matches
Mail list logo