[R] Replacing 9999 and 999 values with NA

Frederic Ntirenganya ntfredo at gmail.com
Sun Feb 22 07:38:04 CET 2015


If you are reading the data frame using for instance read.csv, you can put
in the argument na.string ="9999".
Another way to do that is data[data ==9999] <- NA.

It should be good to tell us how you are reading your dataset.
On Feb 21, 2015 6:49 AM, "Jeff Newmiller" <jdnewmil at dcn.davis.ca.us> wrote:

> You did not say how you imported the data, but if you used one of the
> read.table variants (including read.csv) then you can use the na.strings
> argument as documented in the help file for read.table.
>
> Next time please read the posting guide, as there are some useful tips in
> there, such as posting using plain text (a setting in your email program)
> so we don't get garbled info from you, and providing a reproducible example.
> ---------------------------------------------------------------------------
> Jeff Newmiller                        The     .....       .....  Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live
> Go...
>                                       Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
>
> On February 20, 2015 10:55:30 AM PST, Alexandra Catena <amc5981 at gmail.com>
> wrote:
> >Hello All,
> >
> >I have a data frame of two columns for wind.  The first column is for
> >wind
> >speed and the second wind direction.  I'm trying to replace the 9999
> >values
> >in the first column and the 999 values in the second column with NA.  I
> >tried to use the function ltdl.fix.df but it doesn't seem to do
> >anything.
> >
> >> ltdl.fix.df(windMV, zero2na = FALSE, coded = 999)
> >
> >  n = 9432 by p = 4 matrix checked, 0 NA(s) present
> >
> >  0 factor variable(s) present
> >
> >  5675 value(s) coded 999 set to NA
> >
> >  0 -ve value(s) set to +ve half the negative value
> >
> >
> >I have R version 3.1.1
> >
> >Thanks,
> >Alexandra
> >
> >       [[alternative HTML version deleted]]
> >
> >______________________________________________
> >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list