Message-ID: <A9D95992-DE18-4F5E-9F43-15130AAC244F@comcast.net>
Date: 2012-07-05T19:35:10Z
From: David Winsemius
Subject: Exclude missing values on only 1 variable
In-Reply-To: <6585CBDB-0ACC-4CDC-BF1A-217FBF8AF9DB@comcast.net>
On Jul 5, 2012, at 1:34 PM, David Winsemius wrote:
>
> On Jul 5, 2012, at 1:25 PM, Eiko Fried wrote:
>
>> Hello,
>>
>> I have many hundred variables in my longitudinal dataset and lots of
>> missings. In order to plot data I need to remove missings.
>>
>> If I do
>>> data <- na.omit(data)
>> that will reduce my dataset to 2% of its original size ;)
>>
>> So I only need to listwise delete missings on 3 variables (the ones
>> I am
>> plotting).
>>
>> data$variable1 <-na.omit(data$variable1)
>
> ?complete.cases # returns a logical vector
>
> data[ complete.cases( data[ , c("var1", "var2", "var3"]) , ]
>
> data[ complete.cases( data[ , c("var1", "var2", "var3") ] ) , ]
Er, need to add a right - paren -----here -----------^
>
--
David Winsemius, MD
West Hartford, CT