[R] Output args?

Ben Bolker ben at zoo.ufl.edu
Fri Jun 9 14:48:26 CEST 2000


  You may want to look at the help for "assign", or, as a shortcut, try
the "<<-" version of assignment:

> foo <- function() { a <- 1 }
> foo()
> a
Error: Object "a" not found
> foo <- function() {  a <<- 1 }
> foo()
> a
[1] 1

  Note that this kind of question will eventually lead you into the thick
of issues like environments, scoping, closures, etc. ... but for simple
global assignment I think "<<-" is what you need.

> I find out by trial and error later that you can do the following.
> 
> foo<-function(x,y,z){
>   ...
>   abc<-list(a=x,b=y,c=z)
> }
> 
> and call
> 
> foo(1,2,3)
> 
> there is nothing outputted to the console which is close to what I ask in
> the first part of my query. I'll continue investigating to learn if it's
> possible to export or whatever is the right term, the variables I want so
> that there available for future use at the top level.
> 
> Regards
> 
> Yves Gauvreau
> 
> 

-- 
Ben Bolker                                  bolker at zoo.ufl.edu
Zoology Department, University of Florida   http://www.zoo.ufl.edu/bolker
318 Carr Hall/Box 118525                    tel: (352) 392-5697
Gainesville, FL 32611-8525                  fax: (352) 392-3704

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list