[R] Bug in "transform"?

Vitalie Spinu vitosmail at rambler.ru
Tue Dec 2 18:21:49 CET 2008

On Tue, 02 Dec 2008 17:37:44 +0100, Prof Brian Ripley  
<ripley at stats.ox.ac.uk> wrote:

> 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))

Ok..I got it, it is an usual pain with R: vectors with length 1 are  
recycled and data.frames with nrows=1 and arrays with dim[1]=1 are not.

Will have to use

mtcars[c("t1","t2")]<-with(mtcars, cbind(t1=..., t2=...))

or rewrite transform.data.frame  myself.

Thanks a lot,


More information about the R-help mailing list