[R] How to delete matrix rows based on NA frequency?

Henrique Dallazuanna wwwhsd at gmail.com
Fri Jan 15 13:11:20 CET 2010


Try this:

m[prop.table(rowSums(is.na(m))) < 0.1,]

2010/1/15 Joel Fürstenberg-Hägg <joel_furstenberg_hagg at 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 use the following to calculate the frequencies, thereby getting a new matrix with the frequencies:
>
>
>
> freqNA=rowMeans(is.na(exprdata))
>
>
>
> But is there a shorter way to remove the rows based on "(1-freqNA)>0.1" than looping through the whole matrix using a for loop?
>
>
>
>
>
> All the best,
>
>
>
> Joel
>
> _________________________________________________________________
> Hitta kärleken i vinter!
> http://dejting.se.msn.com/channel/index.aspx?trackingid=1002952
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list