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

Kingsford Jones kingsfordjones at gmail.com
Wed Mar 4 22:44:01 CET 2009

On Wed, Mar 4, 2009 at 2:34 PM, Manli Yan <manliyanrhelp at gmail.com> wrote:
>  Hi:
>  I need to create many variables at one time,how to do this in R?
>  for eg ,X1,X2.......X100?

It depends what you want.  If you want 100 random normal variables of
length 10, stored in a data.frame with names V1, V2, ..., V100 try

dat <- as.data.frame(replicate(100, rnorm(10)))

Kingsford Jones

>  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.

More information about the R-help mailing list