Subject: Re: [R] Output args?
From: Ben Bolker (ben@zoo.ufl.edu)
Date: Fri 09 Jun 2000 - 22:48:26 EST
Message-ID: <Pine.LNX.4.10.10006090840580.16783-100000@bolker.zoo.ufl.edu>
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@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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b25 : Mon 17 Jul 2000 - 12:33:22 EST