David Andel
2003-Apr-24 07:40 UTC
[R] "export" an object froma function for access by ls()
I struggle with this very simple problem: ls() (empty) giveval <- function() { x <- foo eval (x, envir=parent.frame(1)) } ls() (still empty) I did not find anything more promising than eval for this purpose, but how only can I make it to have ls() return x? David
Martin Maechler
2003-Apr-24 09:36 UTC
[R] "export" an object froma function for access by ls()
>>>>> "DavidA" == David Andel <andel at ifi.unizh.ch> >>>>> on 24 Apr 2003 09:40:48 +0200 writes:DavidA> I struggle with this very simple problem: DavidA> ls() DavidA> (empty) DavidA> giveval <- function() { DavidA> x <- foo DavidA> eval (x, envir=parent.frame(1)) DavidA> } DavidA> ls() DavidA> (still empty) probably not. At least "giveval" should be there.. DavidA> I did not find anything more promising than eval for DavidA> this purpose, but how only can I make it to have DavidA> ls() return x? Use assign() instead of eval() ==> ?assign {interesting to hear that computer scientists "across the street" here in Zurich are going into using R !!} Vill Gl?ck, Martin Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <><