Skip to content

Remove missings (quick question)

4 messages · Eiko Fried, Bert Gunter, Marc Schwartz

#
On Nov 9, 2012, at 10:50 AM, Eiko Fried <torvon at gmail.com> wrote:

            
Modify the initial read.csv() call to:

  D <- read.csv("x.csv", na.strings = "-999")

That will convert all -999 values to NA's upon import so that you don't have to post-process it.

See ?read.csv for more info.

Once that is done, R's default behavior is to remove observations with any missing data (eg. NA values) when using modeling functions. Or you can pre-process using:

  D.New <- na.omit(D)

and then use D.New for all of your subsequent analyses. See ?na.omit.

Regards,

Marc Schwartz
#
Marc et. al:
On Fri, Nov 9, 2012 at 9:05 AM, Marc Schwartz <marc_schwartz at me.com> wrote:
when using modeling functions.

This appears to be false. From ?lme (nlme package, nlme_3.1-105, R 2.15.2):

"na.action 	

a function that indicates what should happen when the data contain
NAs. The default action (na.fail) causes lme to print an error message
and terminate if there are any incomplete observations."

Frankly, I doubt that there is any uniformity for practically any
modeling options across the vast array of "modeling functions" in R
and (even recommended?) packages.

Cheers,
Bert

 Or you can pre-process using:

  
    
#
On Nov 9, 2012, at 11:23 AM, Bert Gunter <gunter.berton at gene.com> wrote:

            
Good point Bert. That's what I get for over-generalizing... :-)

Thanks,

Marc