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

2011-03-30 Thread Marc Schwartz
On Mar 30, 2011, at 11:52 AM, Gabor Grothendieck wrote: > On Wed, Mar 30, 2011 at 11:51 AM, peter dalgaard 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

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

2011-03-30 Thread Christopher Desjardins
On Wed, Mar 30, 2011 at 10:51 AM, peter dalgaard 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, > > Chr

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

2011-03-30 Thread Gabor Grothendieck
On Wed, Mar 30, 2011 at 11:51 AM, peter dalgaard 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 > > De

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

2011-03-30 Thread Clint Bowman
Amen. Ditto for "-999.000", "-999.00" and all of the other ones that various (usually Fortran) programmers have used. Has the most recent Fortran standard come around to understanding NA? -- Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTER

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

2011-03-30 Thread peter dalgaard
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 fac

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

2011-03-30 Thread Christopher Desjardins
Ah ... yes. I knew that but clearly didn't at the time of my question or script writing. Thanks, Chris On Wed, Mar 30, 2011 at 8:22 AM, Henrique Dallazuanna wrote: > Try: > > dat0 <- read.table('tim1.dat', na = -999) > Ah ... yes. I knew that but clearly didn't at the time of my question or scri

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

2011-03-30 Thread Muhammad Rahiz
Try using a loop like the following dat0 <- read.table("time1.dat") id <- c("e1dq", "e1arcp", "e1dev", "s1prcp", "s1nrcp","s1ints","a1gpar", "a1pias", "a1devt") for (a in 1:length(id)) { dat0[dat0$id[a]==-999.,as.character(id[a])] <- NA } -- Muhammad Rahiz Researcher & DPhil Candi

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

2011-03-30 Thread Kenn Konstabel
It could be done in a large number of ways depending on how often you need it etc. You might take a look at defmacro in package gtools: # library(gtools) setNA <- macro(df, var, values) { df$var[df$var %in% values] <- NA } then instead of > dat0[dat0$e1dq==-999.,"e1dq"] <- NA you coul

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

2011-03-30 Thread Gavin Simpson
On Wed, 2011-03-30 at 08:15 -0500, Christopher Desjardins wrote: > Hi, > I am trying to write a loop to recode my data from -999 to NA in R. What's > the most efficient way to do this? Below is what I'm presently doing, which > is inefficient. Thanks, > Chris > > >dat0 <- read.table("time1.da

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

2011-03-30 Thread Bernd Weiss
Am 30.03.2011 09:15, schrieb Christopher Desjardins: Hi, I am trying to write a loop to recode my data from -999 to NA in R. What's the most efficient way to do this? Below is what I'm presently doing, which is inefficient. Thanks, Chris dat0<- read.table("time1.dat") colnames(dat0)<- c("e

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

2011-03-30 Thread Uwe Ligges
On 30.03.2011 15:15, Christopher Desjardins wrote: Hi, I am trying to write a loop to recode my data from -999 to NA in R. What's the most efficient way to do this? Below is what I'm presently doing, which is inefficient. Thanks, Chris I think read.table(na.string="-999.") is. Uwe

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

2011-03-30 Thread Henrique Dallazuanna
Try: dat0 <- read.table('tim1.dat', na = -999) On Wed, Mar 30, 2011 at 10:15 AM, Christopher Desjardins wrote: > Hi, > I am trying to write a loop to recode my data from -999 to NA in R. What's > the most efficient way to do this? Below is what I'm presently doing, which > is inefficient. Thanks