[R] Dynamic Variable Names?

Berend Hasselman bhh at xs4all.nl
Sat Apr 14 15:53:38 CEST 2012


On 14-04-2012, at 15:16, johnny123 wrote:

> Hi, I've written some R code that runs through a loop a certain number of
> times.  I want to save the output of each loop under a new variable name,
> but I seem unable to do so.
> 
> I have a [10,1] matrix of stock tickers, and I want to save the output to
> the variable name: paste(matrix[i,1],"rets",sep="").  
> Eg: AAPLrets would be the name of the variable that I would save the output
> to.
> Ideally after the script runs it would have saved 10 output to 10 different
> variable names. 
> Any suggestions on how to do so?
> 

?assign

or consider a list.

Berend



More information about the R-help mailing list