[R] create distinct variable names

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Sat May 14 20:13:57 CEST 2022

as in
assign(paste0('Corr',k), out[[k]]$acf) ## note 'Corr' must be a string!

However, IMO you would do better keeping your results in a list using
lapply(), as overpopulating your workspace with 'suggestive' names is
error prone.


On Sat, May 14, 2022 at 10:34 AM Sorkin, John <jsorkin using som.umaryland.edu> wrote:
> I am trying to create distinct variable names of the form Corr1, Corr2, etc. so that I can run cbind(nurkle,Corrk)
> When I run the code below, I receive the following error message
> Error in paste(Corr,k) <- out[[k]]$acf: could not find the function paste<-
> How can I create a variable name with a sequential number than can be used as the receiving end of my assignment statement?
> nurkle <- out[[1]]$acf
> for (k in 2:10){
>   paste(Corr,k) <- out[[k]]$acf
>    nurkle<- cbind(nurkle,Corrk)
> }
> Thank you,
> John
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

More information about the R-help mailing list