Re: [R] removing NA from a data frame

2012-06-22 Thread Peter Ehlers
On 2012-06-22 01:41, Stuart Leask wrote: Removing rows with NAs, using na.omit(), doesn't seem to be working for me. Dataset: str ( ex10s ) 'data.frame': 2189576 obs. of 5 variables: $ LOPNR : int 58 58 58 58 64 64 64 64 64 64 ... $ DIAGNOS: Factor w/ 173 levels "F20","F200","F2000",..:

Re: [R] removing NA from a data frame

2012-06-22 Thread Prof Brian Ripley
On 22/06/2012 09:41, Stuart Leask wrote: Removing rows with NAs, using na.omit(), doesn't seem to be working for me. It won't if NA is a level of the factor, which is what you seems to have here. For > table(as.factor(c(1,2,NA))) 1 2 1 1 omits NAs by default. Dataset: str ( ex10s )

Re: [R] removing NA from a data frame

2012-06-22 Thread Petr PIKAL
Hi both na.omit and complete cases works for me smoothly when NA is not a valid level in factor. If this is the case, as it seems to be, you need reset your factor levels so that NA is not a valid level. ex10s$dg <- factor( ex10s$dg ) both commands shall work than. Regards Petr > > Removi

Re: [R] removing NA from a data frame

2012-06-22 Thread Stuart Leask
Removing rows with NAs, using na.omit(), doesn't seem to be working for me. Dataset: > str ( ex10s ) 'data.frame': 2189576 obs. of 5 variables: $ LOPNR : int 58 58 58 58 64 64 64 64 64 64 ... $ DIAGNOS: Factor w/ 173 levels "F20","F200","F2000",..: 128 128 128 128 105 105 105 160 105 105 .