R-beta: return()

Bill Simpson (wsimpson@uwinnipeg.ca)
Thu, 25 Sep 1997 12:07:31 -0500 (CDT)


Date: Thu, 25 Sep 1997 12:07:31 -0500 (CDT)
From: Bill Simpson <wsimpson@uwinnipeg.ca>
To: r-testers <r-testers@stat.math.ethz.ch>
Subject: R-beta: return()

I have a question on the use of return(). (Nothing on it in the docs I
have)

The test code below gives the error: Error: Object "x" not found
when I do: thingy2().
How should it be fixed?  Thanks very much for any help!
(My original solution to this sort of problem was to use global variables
x<<-...
y<<-...)

Bill Simpson
-----------------------------
thingy<-function(k)
{
x<-5+k
y<-5-k
return(list(x=x,y=y))
}

thingy2<-function()
{
thingy(10)
cat("x,y:",x,y,"\n")
}

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=