Skip to content
Back to formatted view

Raw Message

Message-ID: <loom.20110416T001127-330@post.gmane.org>
Date: 2011-04-15T22:13:11Z
From: Ben Bolker
Subject: Function for deleting variables with >=50% missing obs from a data frame

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)