[R] question

Petr Pikal petr.pikal at precheza.cz
Mon Jun 7 13:12:07 CEST 2004


Hi

On 7 Jun 2004 at 12:57, zze-PELAY Nicolas FTRD/DMR/BE 
wrote:

> Hello,
> 
> I'd like to know if I can modify a constant value with a function.
> 
> Example :
> 
> a=4
> 
> f1<-function()
> {a=3}

Simply use <<- in the function. But I am not sure if this is 
recommendable way of items manipulating in R.

> f1<-function() a<<-3
> f1()
> a<-4
> a
[1] 4
> f1()
> a
[1] 3

Cheers
Petr

BTW using informative subject is preferable to plain "question" 
statement. :-)

> 
> Of course, after the function f1() is executed , the value of a is
> always 4. I'd like the value returned is 3, like it is possible in C
> by doing *a=3
> 
> 
> Thank you
> 
> nicolas
> 
>  [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal at precheza.cz




More information about the R-help mailing list