0

I have the following vector

years <- c(1996,1997,1998,1999,2000,
           2001,2002,2003,2004,2005,2006,2007,2008,2009,2010)

and I wish to create a list for each number in the vector using a for loop, the name of the list should be the same as the number. Thanks for the help.

sebastian-c
  • 15,057
  • 3
  • 47
  • 93
  • Don't. See this [answer](http://stackoverflow.com/a/6034703/1385941), especially the link to [R FAQ 7.21](http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f) – mnel Feb 15 '13 at 00:51

1 Answers1

3
yearlist <- setNames(vector(length(years), mode="list"), years)
flodel
  • 87,577
  • 21
  • 185
  • 223
sebastian-c
  • 15,057
  • 3
  • 47
  • 93