Reputation: 91
So, here's what I'd like to do:
df <- data.frame(a=1:6, b=1:6)
ss <- magicSubset(df, a <= 3)
ss$b <- 100
df$b # should be c(100,100,100,4,5,6)
Is there something like this in R, or in a package? I guess it would not be too hard to implement... are there reasons it's a bad idea?
Upvotes: 1
Views: 1375
Reputation: 7592
You can subset df$b
and assign it a value:
df$b[df$a <= 3] <- 100
Upvotes: 3