I have the following list which is composed of 12 elements and each element is a vector of length 15.
set.seed(100)
list_data <- replicate(12, sample.int(1000,15),simplify = F)
I would like to extract the first, second, ..., and 15th element of the sublist as follows:
sapply(list_data, '[[',1)
sapply(list_data, '[[',2)
...
sapply(list_data, '[[',15)
and store them in a list:
list(sapply(list_data, '[[',1), sapply(list_data, '[[',2),sapply(list_data, '[[',3),
sapply(list_data, '[[',4), ...,sapply(list_data, '[[',15))
So, in the end, there should be a list of length 15 with each element a list containing a vector of length 12.
I am wondering if I can do it without for loop and maybe with a combination of lapply and sapply?