[R] Bug in "transform"?

Vitalie Spinu vitosmail at rambler.ru
Tue Dec 2 17:14:42 CET 2008


Dear useRs,

Here is a weird behavior of transform function:

   mtcars1<-matcars
   transform(mtcars1,t1=3,t2=4)
Error in data.frame(`_data`, e[!matched]) :
   arguments imply differing number of rows: 32, 1

instead, this works:

   mtcars1$t1<-0
   transform(mtcars1,t1=3,t2=4)

also works if applied in turn:

   transform(mtcars1,t1=3)
   transform(mtcars1,t2=4)

I often need to use this for creating new variables in data frame from  
those already present.
Sorely needed!!

Best,
Vitalie.



More information about the R-help mailing list