[R] Create a data.table by looping over variable names

Matteo Richiardi matteo.richiardi at gmail.com
Wed Dec 16 12:53:19 CET 2015


I apologise for this very basic question, but I found no answers on the web.
I want to create a data.table with n columns, named i1 ... i'n', with only
one row with value = 100 for every variable.

I can do it "by hand":

M.dt <- data.table(i1=100,i2=100,i3=100)

but I would like to make it in a loop, as 'n' is large in my case.


Thanks.

	[[alternative HTML version deleted]]



More information about the R-help mailing list