Re: [R] Quick question: Omitting rows and cols with certain percents of missing values

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Fri, 13 May 2011 10:32:38 -0400

Hi Vickie,

You might try the following:

# some data
set.seed(123)
X <- matrix(rnorm(1000), ncol = 20)
X[sample(1000, 100)] <- NA

# excluding rows with NA >20%
X[!rowMeans(is.na(X)) > 0.2, ]

# excluding columns with NA >10%
X[, !colMeans(is.na(X)) > 0.1]

See ?is.na, ?rowMeans and ?colMeans for more information.

HTH,
Jorge

On Fri, May 13, 2011 at 9:42 AM, Vickie S <> wrote:

>
> Hi
> naive question.
> It is possible to get R command for omitting rows or cols with missing
> values present.
>
> But
> if i want to omit rows or cols with i.e . >20% missing values, I
> couldīt find any package-based command, probably because it is too
> simple for anyone to do that manually, though not for me. Can anyone
> please help me ?
>
> - vickie
>
>
>
>
>
>
>
>
>
>
>
>
> [[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.
>
>

        [[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. Received on Fri 13 May 2011 - 14:35:41 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 13 May 2011 - 15:00:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive