Skip to content
Back to formatted view

Raw Message

Message-ID: <971536df0812020819i29291fcax90c930fd0d5fbdcf@mail.gmail.com>
Date: 2008-12-02T16:19:07Z
From: Gabor Grothendieck
Subject: Bug in "transform"?
In-Reply-To: <op.uljl2srrw9ljuw@tir-070312.staff.few.eur.nl>

Try:

cbind(mtcars, t1 = 3, t2 = 4)

On Tue, Dec 2, 2008 at 11:14 AM, Vitalie Spinu <vitosmail at rambler.ru> wrote:
> 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.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>