-1
I’m working on an environmental model that returns a list of vectors. Each list corresponds to a point in space, and each vector is a time series of data for different variables. I’m trying to extract each vector from each list to create matrices, one for each variable.
The structure I’m trying to convert looks like this:
t <- list(list("r" = c(1,2,3), "e" = c(4,5,6), "t" = c(7,8,9)),
list("r" = c(11,12,13), "e" = c(14,15,16), "t" = c(17,18,19)))
I want it to become that:
t0 <- list("r" = do.call(rbind, list(c(1,2,3), c(11,12,13))),
"e" = do.call(rbind, list(c(4,5,6), c(14,15,16))),
"t" = do.call(rbind, list(c(7,8,9), c(17,18,19))))
How could I do this conversion without specifying the names of the columns, but still keeping them to access using the operator $
?