[R] how to create many variables at one time?

Eik Vettorazzi E.Vettorazzi at uke.uni-hamburg.de
Wed Mar 4 22:45:25 CET 2009

Hi Manli,
you may consider structuring your data in some appropriate form like 
data.frame or list. Its often not the best way holding information 
separated in many variables.
But if you *really* want to create 100 separate variables, something like

for (i in 1:100) assign(paste("X",i,sep=""), some_values)

will do the job.

Manli Yan schrieb:
>   Hi:
>   I need to create many variables at one time,how to do this in R?
>   for eg ,X1,X2.......X100?
>  Thanks~
> 	[[alternative HTML version deleted]]
> ______________________________________________
> 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.

Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/42803-8243
F ++49/40/42803-7790

More information about the R-help mailing list