Skip to content

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

2 messages · David Andel, Martin Maechler

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