Hi Dennis
Yes you are completely right. Well, we use to say "Quick work is wretched
work" and this is perfect example.
Regards
Petr
> Hi Petr:
>
> You might want to double check your post. The OP wanted to remove
> cases where *all* the variables in a row were NA. complete.cases()
> eliminates
Good morning Peter,
No, I don't think complete cases gets what the OP wants. He wants to
only throw out those rows that are entirely NA while complete.cases()
gets rows with any NA's.
Best,
Michael
2011/11/7 Petr PIKAL :
>>
>> Perhaps something like this will work.
>>
>> df[!(rowSums(is.na(df))
>
> Perhaps something like this will work.
>
> df[!(rowSums(is.na(df))==NCOL(df)),]
Or
df[complete.cases(df),]
Regards
Petr
>
> Michael
>
> On Fri, Nov 4, 2011 at 9:27 AM, Jose Iparraguirre
> wrote:
> > Hi,
> >
> > Imagine I have the following data frame:
> >
> >> a <- c(1,NA,3)
> >> b <
It does!
Thanks,
José
-Original Message-
From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com]
Sent: 04 November 2011 15:18
To: Jose Iparraguirre
Cc: r-help@r-project.org
Subject: Re: [R] How to delete only those rows in a dataframe in which all
records are missing
Perhaps
Perhaps something like this will work.
df[!(rowSums(is.na(df))==NCOL(df)),]
Michael
On Fri, Nov 4, 2011 at 9:27 AM, Jose Iparraguirre
wrote:
> Hi,
>
> Imagine I have the following data frame:
>
>> a <- c(1,NA,3)
>> b <- c(2,NA,NA)
>> c <- data.frame(cbind(a,b))
>> c
> a b
> 1 1 2
> 2 NA NA
Hi,
Imagine I have the following data frame:
> a <- c(1,NA,3)
> b <- c(2,NA,NA)
> c <- data.frame(cbind(a,b))
> c
a b
1 1 2
2 NA NA
3 3 NA
I want to delete the second row. If I use na.omit, that would also affect the
third row. I tried to use a loop and an ifelse clause with is.na to get
6 matches
Mail list logo