[R] How can I create a data_table with 1000 variables (Var1:Var1000)

Siraaj Khandkar siraaj at khandkar.net
Thu Aug 15 22:33:23 CEST 2013


On 08/15/2013 04:16 PM, Pooya Lalehzari wrote:
> Hello everyone,
> How can I create a data_table with 1000 variables (Var1:Var1000)?
>

I'm not familiar with data_table, but here's an example to get you 
started in figuring this out:

 > n <- 3
 > var.range <- 1:n
 > prefix <- "Var"
 > data <- as.data.frame(as.list(var.range))
 > names(data) <- paste(prefix, var.range, sep="")
 > data
   Var1 Var2 Var3
1    1    2    3



More information about the R-help mailing list