Re: [R] How to delete only those rows in a dataframe in which all records are missing

2011-11-07 Thread Petr PIKAL
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

Re: [R] How to delete only those rows in a dataframe in which all records are missing

2011-11-07 Thread R. Michael Weylandt
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))

Re: [R] How to delete only those rows in a dataframe in which all records are missing

2011-11-07 Thread Petr PIKAL
> > 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 <

Re: [R] How to delete only those rows in a dataframe in which all records are missing

2011-11-04 Thread Jose Iparraguirre
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

Re: [R] How to delete only those rows in a dataframe in which all records are missing

2011-11-04 Thread R. Michael Weylandt
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

[R] How to delete only those rows in a dataframe in which all records are missing

2011-11-04 Thread Jose Iparraguirre
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