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.

1
  • Don't. See this answer, especially the link to R FAQ 7.21 Commented Feb 15, 2013 at 0:51

1 Answer 1

3
yearlist <- setNames(vector(length(years), mode="list"), years)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.