[R] Feature or bug?
Sigbert Klinke
sigbert at wiwi.hu-berlin.de
Thu May 21 11:45:26 CEST 2015
Hi,
if I run
update <- function (newtime) { ginput <<- list(time=newtime)}
server <- function (input) {
print(paste("Before", input$time))
update(1)
print(paste("After:", input$time))
}
ginput <- list(time=0)
server(ginput)
then I get as result
[1] "Before 0"
[1] "After: 0"
If I uncomment the first print
update <- function (newtime) { ginput <<- list(time=newtime) }
server <- function (input) {
#print(paste("Before", input$time))
update(1)
print(paste("After:", input$time))
}
ginput <- list(time=0)
server(ginput)
then I get
[1] "After: 1"
Even when I use a side effect (by assign some new value to a global
variable) I would have expected the same behaviour in both cases.
Sigbert
--
http://u.hu-berlin.de/sk
More information about the R-help
mailing list