Re: [R] Access comonents in lists of lists

2013-01-11 Thread David Winsemius
On Jan 11, 2013, at 3:26 PM, Bjoern Helm wrote: > 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

Re: [R] Access comonents in lists of lists

2013-01-11 Thread Bjoern Helm
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

Re: [R] Access comonents in lists of lists

2013-01-11 Thread Rolf Turner
On 01/12/2013 12:40 AM, Bjoern Helm wrote: 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]][[

Re: [R] Access comonents in lists of lists

2013-01-11 Thread Ista Zahn
lapply(lst, function(x) return(x[[2]])) On Fri, Jan 11, 2013 at 6:40 AM, Bjoern Helm wrote: > 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]