Re: [R] Quick recode of -999 to NA in R

From: Christopher Desjardins <cddesjardins_at_gmail.com>
Date: Wed, 30 Mar 2011 12:18:44 -0500

On Wed, Mar 30, 2011 at 10:51 AM, peter dalgaard <pdalgd_at_gmail.com> wrote:

>
> On Mar 30, 2011, at 16:05 , Christopher Desjardins wrote:
>
> >>
> >> dat0 <- read.table('tim1.dat', na = -999)
> >>
> >
> > Ah ... yes. I knew that but clearly didn't at the time of my question or
> > script writing.
> > Thanks,
> > Chris
>
> Depending on where your data came from, you could get caught by the fact
> that the above is really ...na.strings="-999"... and that is not going to
> work if the actual code is (say) -999.00.
>
> Another straightforward option is dat0[dat0 == -999] <- NA
>
>
Thanks Peter. That way does work well too and it does what I need. Chris

>
> --
> Peter Dalgaard
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: pd.mes_at_cbs.dk Priv: PDalgd_at_gmail.com
>
>

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
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. Received on Wed 30 Mar 2011 - 17:33:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 30 Mar 2011 - 17:50:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive