[R] How define global Variable?

Gichangi, Anthony anthony at stat.sdu.dk
Mon Nov 28 15:40:03 CET 2005


In your current definitions a can not change value to
"new" unless you type  a<-test(). If you want the
results of the test to be global then you add something like this

test <-function()a<<-"new"

This will always replace the existing value of a once
you type test()



regards
Anthony----- Original Message ----- 
From: <svenknueppel at reilich.net>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, November 28, 2005 3:26 PM
Subject: [R] How define global Variable?


> Hello,
>
> I try to define a global variable.
>
> 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