Skip to content
Prev 157318 / 398506 Next

Return a list

But why do this? Just leave the (preferably named) variables as list
components and work with them there.

1. ?comment tells you how to add a comment attribute to the list for self
documentation (what were the components? how are they related? etc.)

2. ?with  shows you how to access the components of the list individually in
the "usual" way.

3. ?lapply and friends shows you how to "loop" over list components .

etc.

Cheers,
Bert

Bert Gunter 
Genentech  

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Wacek Kusnierczyk
Sent: Friday, September 26, 2008 12:40 PM
To: Mike Prager
Cc: R help
Subject: Re: [R] Return a list
Mike Prager wrote:
output variables.
them all down?
arguably ugly and risky, but simple:

for (name in names(result)) assign(name, result[[name]])

(note, for this to work you actually need to name the components of the
returned list: return(list(a=a,b=b,...)))

vQ

______________________________________________
R-help at 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-guide.html
and provide commented, minimal, self-contained, reproducible code.