Skip to content
Prev 163581 / 398506 Next

Bug in "transform"?

As the help page says

      If some of the values are not vectors of the appropriate length,
      you deserve whatever you get!

So you can use

mtcars1 <- mtcars
mtcars1[c("t1", "t2")] <- cbind(rep(3,32), rep(4, 32))

or even

mtcars1 <- transform(mtcars, t1=rep(3, 32), t2=rep(4, 32))
Vitalie Spinu wrote:
'works'?  Only if you assign the result.
Just learn to use indexing: transform() is just syntactic sugar that you 
are not making use of.