I got many answers to the question I asked below , and I thank you all.
Several of you told me to use ->> but told also that "it is not a
recommendable way of items manipulating in R".
I don't really understand what it exactly means :
1) does it mean it's not a very good way of programming , a
dangerous way of programming because the variable a can be modified ? ,
etc
Or 2) does it mean that R is not done to manipulate the operation
->> in a function in a safe way , that there can be some mistakes, that
the memory allocation is not forseen for this case?
I indeed saw in the archive the function f <- function(x) { g <-
function() x[1] <<- x[1]+1; g() } # g nested , which is an exemple of
function where x (of the global environnement) won't be modified when
doing f(x) , but I'm not in the case of complicated programmes such as
f.
I am just carefull because in my programmes, I use arrays with important
datas , and it would better for my programmes to be able to modify some
variables (of the global environnement) directly in my function by using
->>. Consequently, I just want to be sure that I will note have false
results , and that i won't have problems I can't deal with (such as
allocation memory).
So , is it 1) or 2) ?
Thank you
Nicolas
----------------------
* Former question :
I'd like to know if I can modify a constant value with a function.
Example :
a=4
f1<-function()
{a=3}
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
[[alternative HTML version deleted]]