Re: [R] modify a data frame by values in the columns

2011-06-04 Thread Peter Ehlers
On 2011-06-04 11:11, Peter Ehlers wrote: On 2011-06-03 13:34, Jason024 wrote: I have a data frame like this: col1 col2 r1 21 r2 43 r3 65 r4 87 r5109 r612 11 r714 13 r816 15 r918 17 r10 20 19 I want to modify this data fr

Re: [R] modify a data frame by values in the columns

2011-06-04 Thread Peter Ehlers
On 2011-06-03 13:34, Jason024 wrote: I have a data frame like this: col1 col2 r1 21 r2 43 r3 65 r4 87 r5109 r612 11 r714 13 r816 15 r918 17 r10 20 19 I want to modify this data frame, for example, assign every row in colum

Re: [R] modify a data frame by values in the columns

2011-06-03 Thread Muhammad Rahiz
Hi Jason, This is one way; c1 <- seq(2,20,2) c2 <- seq(1,19,2) c3 <- cbind(c1,c2) c3[,1][which(c3[,1]<12)] <- -1 c3[,2][which(c3[,2]>10)] <- -1 Muhammad On Fri, 3 Jun 2011, Jason024 wrote: I have a data frame like this: col1 col2 r1 21 r2 43 r3 65 r4 87 r

[R] modify a data frame by values in the columns

2011-06-03 Thread Jason024
I have a data frame like this: col1 col2 r1 21 r2 43 r3 65 r4 87 r5109 r612 11 r714 13 r816 15 r918 17 r10 20 19 I want to modify this data frame, for example, assign every row in column col1 and col2 to -1 if the values in c