[R] "export" an object froma function for access by ls()

Martin Maechler maechler at stat.math.ethz.ch
Thu Apr 24 11:36:53 CEST 2003


>>>>> "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			<><



More information about the R-help mailing list