[R] How define global Variable?

Uwe Ligges ligges at statistik.uni-dortmund.de
Mon Nov 28 15:46:03 CET 2005


svenknueppel at reilich.net wrote:

> Hello,
> 
> I try to define a global variable.

You should not do that unless you really know why you want it this way. 
You probably want to read the R Language Definition manual.

Anyway, read ?assign if you want to proceed doing dangerous things.

Uwe Ligges



> My example:
> 
> R> a <- "old"
> R> test <- function () { a <- "new" }
> R> test()
> R> a # shoud be "new"
> 
> This doesn't work. I would like to modify the variable "a" in a
> procedure. How can I do that.
> 
> Thank you for helping.
> 
> Sven Knüppel (Germany-Berlin)
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list