[R] Subassignments involving NAs in data frames

2005-06-09 Thread McGehee, Robert
I'm seeing some inconsistent behavior when re-assigning values in a data frame. The first assignment turns all of the 0s in my data frame to 2s, the second fails to do so. df1 - data.frame(a = c(NA, 0, 3, 4)) df2 - data.frame(a = c(NA, 0, 0, 4)) df1[df1 == 0] - 2 ## Works df2[df2 == 0] - 2

Re: [R] Subassignments involving NAs in data frames

2005-06-09 Thread Thomas Lumley
On Thu, 9 Jun 2005, McGehee, Robert wrote: I'm seeing some inconsistent behavior when re-assigning values in a data frame. The first assignment turns all of the 0s in my data frame to 2s, the second fails to do so. df1 - data.frame(a = c(NA, 0, 3, 4)) df2 - data.frame(a = c(NA, 0, 0, 4))

Re: [R] Subassignments involving NAs in data frames

2005-06-09 Thread Prof Brian Ripley
On Thu, 9 Jun 2005, Thomas Lumley wrote: On Thu, 9 Jun 2005, McGehee, Robert wrote: I'm seeing some inconsistent behavior when re-assigning values in a data frame. The first assignment turns all of the 0s in my data frame to 2s, the second fails to do so. But they differ in several ways, so