Re: [R] Adding new columns to (output) data - e.g., read 5 cols write 8

From: Esmail Bonakdarian <esmail.js_at_gmail.com>
Date: Wed, 11 Jun 2008 22:49:06 -0400

Hi Erik,

Erik Iverson wrote:
> Esmail -
>
> Are these 5 vectors of data stored in a data.frame? I assume so.

Yes, I do a simple load() call first to read the .rda file ...

> test2 <- transform(test, d = 2*a + b, e = 3*c)
> save(test2, file = "test2.Rdata")
>
> Does this help?

Yes it does .. this is just what I needed. I'll probably do it in this way:

df=transform(df, X5=X1+X2)
df=transform(df, X6=X1-X2)
etc ...

building it up the df line by line since the definitions have been provided one per line (instead of queuing them up in one line like you showed). I'll have to write a little awk or ruby script to take the original definitions and wrap them into the transform call, but then I should be all set to go.

Thanks again!

Esmail



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. Received on Thu 12 Jun 2008 - 02:53:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 12 Jun 2008 - 03:30:53 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive