Skip to content
Prev 343575 / 398506 Next

Unexpected behavior when giving a value to a new variable basedon the value of another variable

On Aug 29, 2014, at 8:54 PM, David McPearson wrote:

            
Not sure what you are seeing. I am seeing what you expected:

 > test <- data.frame(age=1:10, sample=1)
 > test$sample[test$age<5] <- 2
 > test
    age sample
1    1      2
2    2      2
3    3      2
4    4      2
5    5      1
6    6      1
7    7      1
8    8      1
9    9      1
10  10      1