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:
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
Try this:
m[prop.table(rowSums(is.na(m))) 0.1,]
2010/1/15 Joel Fürstenberg-Hägg joel_furstenberg_h...@hotmail.com:
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
3 matches
Mail list logo