[R] external variable by inside-function routines modifications
Alex Bird
sunduck at gmail.com
Thu Oct 8 19:22:31 CEST 2009
Is it possible to do what you mentioned somehow outside of the
function. I mean that there's some function and the only thing I can
do is to point on the variable to be modified inside the function
without any possibilities to modify the very function.
2009/10/8 Henrique Dallazuanna <wwwhsd at gmail.com>:
> See assign, you can use '<<-' assignment:
>
> foo <- function(var) var <<- var + 1
>
> On Thu, Oct 8, 2009 at 2:14 PM, devol <sunduck at gmail.com> 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.
>>
>> Thanks!
>> --
>> View this message in context: http://www.nabble.com/external-variable-by-inside-function-routines-modifications-tp25803308p25803308.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>
More information about the R-help
mailing list