Skip to content

what's the best way to save global variables?

2 messages · johan Faux, Stephen D. Weigand

#
Johan,
On Sep 15, 2005, at 11:39 AM, johan Faux wrote:

            
In most cases, you would write a function that would
return an object of class list, the components of
which would be the values you want to use later.
For example

myfun <- function([stuff]){

  [stuff]

  return(list = (var1 = val1, var2 = val2)
}

and your call would be

glob <- myfun([stuff])

and you would access val1 with

glob$var1
Use

source("glob.R")

Check out "An introduction to R" 
(http://cran.r-project.org/doc/manuals/R-intro.html).

Stephen