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

2008-06-11 Thread Esmail Bonakdarian
Hello, I have the following task I'd like to accomplish: A file contains 5 columns of data (several hundred rows), let's call them a, b, c, d and e (ie these are their column headers) I also have a set of definitions, e.g., f = a + b g = a * 3 h = c + d etc. I would like to write out a new

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

2008-06-11 Thread jim holtman
yourDF - cbind(yourDF, f=yourDF$a+yourDF$b, g=yourDF$a * 3, h=yourDF$c + yourDF$d) On Wed, Jun 11, 2008 at 9:26 PM, Esmail Bonakdarian [EMAIL PROTECTED] wrote: Hello, I have the following task I'd like to accomplish: A file contains 5 columns of data (several hundred rows), let's call them a,

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

2008-06-11 Thread Erik Iverson
Esmail - Esmail Bonakdarian wrote: Hello, I have the following task I'd like to accomplish: A file contains 5 columns of data (several hundred rows), let's call them a, b, c, d and e (ie these are their column headers) Are these 5 vectors of data stored in a data.frame? I assume so. I

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

2008-06-11 Thread Esmail Bonakdarian
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

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

2008-06-11 Thread Esmail Bonakdarian
jim holtman wrote: yourDF - cbind(yourDF, f=yourDF$a+yourDF$b, g=yourDF$a * 3, h=yourDF$c + yourDF$d) Thanks Jim, I also learned about the transform() method from Erik which will also work beautifully. Esmail __ R-help@r-project.org mailing list