Re: [R] Updating a data frame based on if condition

2014-02-18 Thread Jeff Johnson
anging a condition is pretty simple > > David C > > From: Jeff Johnson [mailto:mrjeffto...@gmail.com] > Sent: Tuesday, February 18, 2014 12:54 PM > To: dcarl...@tamu.edu > Cc: R help > Subject: Re: [R] Updating a data frame based on if condition > > Ahh, I was

Re: [R] Updating a data frame based on if condition

2014-02-18 Thread David Carlson
E FALSE FALSE TRUE TRUE FALSE TRUE FALSE FALSE TRUE TRUE [49] TRUE TRUE And adding or changing a condition is pretty simple David C From: Jeff Johnson [mailto:mrjeffto...@gmail.com] Sent: Tuesday, February 18, 2014 12:54 PM To: dcarl...@tamu.edu Cc: R help Subject: Re: [R] Updating a d

Re: [R] Updating a data frame based on if condition

2014-02-18 Thread arun
Hi, I don't know whether the 'mydata" object was updated or not before you run the table. mydata <- within(mydata,FNAME_SUSPECT <- FNAME_TOKEN_COUNT >10|FNAME_LENGTH>45|regexpr("9",FNAME_PATTERN)==0) table(mydata$FNAME_SUSPECT) # #FALSE #   50 Now, your second condition (reply to Davi

Re: [R] Updating a data frame based on if condition

2014-02-18 Thread Jeff Johnson
R Cookbook. > > > On Tue, Feb 18, 2014 at 10:16 AM, David Carlson wrote: > >> Not always true, but it is in this case: >> >> ?ifelse >> >> David C >> >> -Original Message- >> From: r-help-boun...@r-project.org >> [mailto:r-he

Re: [R] Updating a data frame based on if condition

2014-02-18 Thread Jeff Johnson
.@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Johnson > Sent: Tuesday, February 18, 2014 11:24 AM > To: R help > Subject: [R] Updating a data frame based on if condition > > I have a subset of data that I have identified as "suspect" (f

Re: [R] Updating a data frame based on if condition

2014-02-18 Thread David Carlson
Not always true, but it is in this case: ?ifelse David C -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Johnson Sent: Tuesday, February 18, 2014 11:24 AM To: R help Subject: [R] Updating a data frame based on if condition I

[R] Updating a data frame based on if condition

2014-02-18 Thread Jeff Johnson
I have a subset of data that I have identified as "suspect" (for example, the first name has excessive spaces, is longer than 35 characters or has a number). What I want to do is update the FNAME_SUSPECT field in "mydata" to TRUE if any of those conditions are met. Here's my data: > dput(mydata)

Re: [R] Updating a Data Frame

2010-07-22 Thread Nikhil Kaza
Looks like your event id is unique. If that is so, why not just do ##Not checked events <- events[sort(events$event),] dataF <- dataF[sort(data$event),] if(doUpdate == 1){ if(!is.null(dataF) && nrow(dataF) > 0){ events[events$eventid %in% dataF$event, c("timestamp", "isSynchronized","ti

[R] Updating a Data Frame

2010-07-22 Thread harsh yadav
Hi, I have a global data-frame in my R script. At some point in my script, I want to update certain columns of this data-frame by calling in an update function. The function looks like this: # get events data. This populates a global event data frame in the R-script events <- getEvents(con, ev

Re: [R] Updating a data frame

2009-04-03 Thread Seeliger . Curt
To my earlier question about updating a dataframe, and certainty that this has been solved several times before, Dr. Winsemius suggests (Thanks!): > I am sure this is not the most elegant method, but it will "work". > > new <- merge(nn,uu, by = c("a","b"), all.x=T) > new$y <- with( new, (ifelse(

Re: [R] Updating a data frame

2009-04-02 Thread David Winsemius
I am sure this is not the most elegant method, but it will "work". > new <- merge(nn,uu, by = c("a","b"), all.x=T) > new a bx.xy.x x.y y.y 1 1 1 0.03648491 0.69644753 100 -100 2 1 2 0.76826365 0.28821953 NA NA 3 1 3 0.62744363 0.08373154 NA NA 4 2 1 0.27503185 0.557

[R] Updating a data frame

2009-04-02 Thread Seeliger . Curt
Folks, Updating values in a table is simple in SAS or SQL, but I've wracked my brain looking for an elegant solution in R to no avail thus far. Certainly this is a common need that's been solved in dozens of different ways. Given an initial dataframe nn and a smaller dataframe of updates uu, I'