[R] modifications of out-of-the-function variable

Ben Bolker bolker at ufl.edu
Thu Oct 8 20:13:57 CEST 2009




devol wrote:
> 
> Dear all,
> 
>   could you please advice whether it is possible somehow to modify an
> external (from the point of some function view) variable by some
> function-internal operators. For example
> 
>> var=1
>> foo<-function(var){var=var+1}
>> foo(var)
>> var
> [1] 1
> 
> but the goal is to get the var equal to 2 in this specific case. Maybe it
> is possible to set the var as some kind of global type and then it will be
> returned from the function as I want it to see... 
> 
> Thanks!
> 

?"<<-" 

although this should be used sparingly.  See section 6  of
<http://www.burns-stat.com/pages/Tutor/R_inferno.pdf> ...
-- 
View this message in context: http://www.nabble.com/modifications-of-out-of-the-function-variable-tp25803308p25803347.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list