[R] Creating new columns inside a loop

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Aug 10 21:55:01 CEST 2005


"David L. Van Brunt, Ph.D." <dlvanbrunt at gmail.com> writes:

> Ok, I know R isn't an optimal environment for looping (or so I've heard) but 
> I have a need to loop through columns of data and create new columns of data 
> based on calculations within rows...
> 
> I'm sure there's a help file, but I'm not sure what search terms to use to 
> find it! The problem is that these new columns need to have names that I can 
> later access... Like NewVar1, NewVar2, etc.... 
> 
> In php I'd call this "indirection" but I'm not sure what to call it in R so 
> that I can find instructions on how to create, name, and address the values 
> stored this way...
> 
> any gentle nudges in the right direction would be greatly appreciated!

A little more information about what you're actually trying to do and
I'm sure someone will give you a nudge with a sledgehammer...

At present, your description is just that little bit too nebulous.

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907




More information about the R-help mailing list