Re: [R] How to get a specific named element in a nested list

2010-11-11 Thread Keith Jewell
on: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] >> Im >> Auftrag von Michael Bedward >> Gesendet: Donnerstag, 11. November 2010 10:56 >> An: friedericksen.h...@gmail.com >> Cc: r-h...@stat.math.ethz.ch >> Betreff: Re: [R] How to get a speci

Re: [R] How to get a specific named element in a nested list

2010-11-11 Thread Michael Bedward
richt- >> Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im >> Auftrag von Michael Bedward >> Gesendet: Donnerstag, 11. November 2010 10:56 >> An: friedericksen.h...@gmail.com >> Cc: r-h...@stat.math.ethz.ch >> Betreff: Re: [R] How

Re: [R] How to get a specific named element in a nested list

2010-11-11 Thread Friedericksen Hope
Hi Ivan, thank you very much for your detailed explanations and response! Please excuse, that I did not include a reproducible example. Yes, what I am looking for is such a function - but I suspect, that it does not exist already, so I have to write it on my own. Best, Friedericksen On 11/11/

Re: [R] How to get a specific named element in a nested list

2010-11-11 Thread Janko Thyson
b=list(b.1=list(b.1.1="a"), b.2="b"), c="a" )) # RETRIEVE 'COMPLETE' INDEX (A DATA FRAME; NAMES AND INDEX) listnames.get(list.obj=my.list, do.basename=TRUE, do.name.chain=TRUE) # GET RECURSIVE INDEX ONLY idx <- listbranch.get(list.obj=my.list

Re: [R] How to get a specific named element in a nested list

2010-11-11 Thread Michael Bedward
Hi Friedericksen, This function will do it. No doubt there are more elegant ways :) rmatch <- function(x, name) { pos <- match(name, names(x)) if (!is.na(pos)) return(x[[pos]]) for (el in x) { if (class(el) == "list") { out <- getEl(el, name) if (!is.null(out)) return(o

Re: [R] How to get a specific named element in a nested list

2010-11-11 Thread Ivan Calandra
Hi, A reproducible example would have been nice, but a correct code even more (you forgot some commas)! So if you meant this: x <- list( list( list(df1,df2), list(df3, list(df4,df5)), list(df6,df7))) check str(x): (I removes the details of each df) List of 1 $ :List of 3 ..

[R] How to get a specific named element in a nested list

2010-11-11 Thread Friedericksen Hope
Hello, I have a nested named list structure, like the following: x <- list( list( list(df1,df2) list(df3, list(df4,df5)) list(df6,df7))) with df1...d7 as data frames. Every data frame is named. Is there a way to get a specific named element