Hi,
thank you. I just came up with
lapply(c(1:length(lst)), function(x) return(lst[[x]][[2]]))
but your solution is much more elegant. Although I don't completely understand:
if lst is the argument of function x[[2]] this should be iterpreted as
lst[[2]]. Where am I wrong?
Björn
Am 11.01.20
Dear R users,I have a list of equally structured lists, how can I access e.g.
all 2nd compontents in those sub-lists?An example:lst <-
list(rep(list(1:3),3), rep(list(4:6),3))> lst[[1]][[1]][[1]][1] 1 2
3[[1]][[2]][1] 1 2 3[[1]][[3]][1] 1 2 3[[2]][[2]][[1]][1] 4 5 6[[2]][[2]][1]
4 5 6[[2]][[3]][1]
2 matches
Mail list logo