Wrap each element in an environment, flatten that and then
extact the element in each environment. (Be sure not to use
an old version of R since sufficiently far back R had a bug when
environments were stored in lists that was since fixed.)
L <- rapply(test.list, function(el) environment(), how =
Prof Brian Ripley wrote:
>
> See ?rapply
Golly, the things one learns when least expecting it.
Jim
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guid
Hi,
thanks a lot for your help. Somehow rapply had escaped my notice. I
also have a follow-up question on that. I would like to "flatten" my
output list to a list with only one level. Option "unlist" in rapply
returns a character vector, in my example:
> rapply(test.list, rev, how="unlist")
Georg Otto wrote:
Hi,
I have a question about applying a function recursively through a
list. Suppose I have a list where the different elements have
different levels of recursion:
...
I understand that with a fixed number of recursion levels one can use
lapply() in a nested way, but what i
on 06/11/2008 10:51 AM Georg Otto wrote:
Hi,
I have a question about applying a function recursively through a
list. Suppose I have a list where the different elements have
different levels of recursion:
test.list<-list("I"=list("A"=c("a", "b", "c"), "B"=c("d", "e", "f"), "C"=c("g", "h",
"i"
See
?rapply
for your example
rapply( test.list, rev, how='replace' )
HTH,
Chuck
On Wed, 11 Jun 2008, Georg Otto wrote:
Hi,
I have a question about applying a function recursively through a
list. Suppose I have a list where the different elements have
different levels of
See ?rapply
On Wed, 11 Jun 2008, Georg Otto wrote:
Hi,
I have a question about applying a function recursively through a
list. Suppose I have a list where the different elements have
different levels of recursion:
test.list<-list("I"=list("A"=c("a", "b", "c"), "B"=c("d", "e", "f"), "C"=c("
Hi,
I have a question about applying a function recursively through a
list. Suppose I have a list where the different elements have
different levels of recursion:
> test.list<-list("I"=list("A"=c("a", "b", "c"), "B"=c("d", "e", "f"),
> "C"=c("g", "h", "i")),
+ "II"=list("A"=lis
8 matches
Mail list logo