I am trying to create a list of lists in R but the interior list are only being stored as temp variables as I go through a loop and when I try to access one of the sub-lists inside of the larger list, I only receive the first element of the sub-list.
I found this answer R. how make list of lists in R? but it is not working for me and I think it might be due to the fact that I am not storing each list.
Here is my code:
list1 <- list(1,2,3,4,5) allLists <- list() for(i in 1:5){ allLists[i] = list1 } newlst = allLists[[3]] newlst[2] #[[1]] #NULL I wold like to be able to access all the lists within allLists but it does not let me. The value for newlst is 1 when I would like it to be the list (1,2,3,4,5)
allLists[[i]] <- list1in the for-loop?