Thanks Yihui for this complementary explanaition.
May I suggest to change the "Scoping" section of the tutorial regarding
to this ?
http://rstudio.github.io/shiny/tutorial/#scoping
Because this tutorial describes "<<-" only for "Objects visible across
all sessions", which is not that you described.
Thanks for your return,
Gregoire
Le 17/12/2013 08:47, Yihui Xie a �crit :
> "<<-" is commonly misunderstood by R users. It is not an operator for
> "global assignment". It only means a non-local assignment. When the
> object is not defined in any of the parent environments, <<- becomes a
> global assignment operator. In your case, as long as you have defined
> "x" in a parent environment, you can use <<- to modify it in child
> environments. See ?`<<-` for a detailed explanation.
>
> ls()
> f <- function() {
> x <- 0
> g <- function() {x <<- 1}
> g()
> x
> }
> f()
> ls()
>
> Regards,
> Yihui
>
>
> On Tue, Dec 17, 2013 at 1:28 AM, St�phane Laurent <
lauren...@yahoo.fr> wrote:
>> Yes, actually I had already encountered this problem when I did this app:
>>
http://glimmer.rstudio.com/stla/reactive1/
>>
>> But if we do x <<- c(x, input$go), the same problem as Gr�goire will occur,
>> no ? Or there's no problem when we do a global assignment inside the body of
>> shinyServer() ?
>>
>>
>> Le mardi 17 d�cembre 2013 07:13:32 UTC+1, Yihui Xie a �crit :
>>>
>>> You can use x <<- c(x, input$go).
>>>
>>> Or use an environment, e.g. env <- new.env(); env$x <- c(env$x, input$go).
>>>
>>> Regards,
>>> Yihui
>>>
>>>
>>> On Mon, Dec 16, 2013 at 3:51 AM, St�phane Laurent <
lauren...@yahoo.fr>