Re: [R] Function for deleting variables with >=50% missing obs from a data frame from Ben Bolker on 2011-04-16 (R help archive)

Re: [R] Function for deleting variables with >=50% missing obs from a data frame

From: Ben Bolker <bbolker_at_gmail.com>
Date: Fri, 15 Apr 2011 22:13:11 +0000

Rita Carreira <ritacarreira <at> hotmail.com> writes:

> I have several data frames where some of the variables have many
> missing observations. For example, Q1 in
> one of my data frames has over 66% of its observations missing.
> I have tried imputation with mice but it does
> not work for all the data frames and I get the following
> message or a similar message to this:
>

  How about

missing_prop <- sapply(orig_data,function(x) { mean(is.na(x)) }) good_data <- orig_data[missing_prop>0.5]

 (untested)



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 15 Apr 2011 - 22:17:28 GMT

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 15 Apr 2011 - 22:20:31 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