Reactive R/Shiny Example Fails after Parameterizing One Variable -


i have following simple , working shiny-rmarkdown document. produces slider , outputs date below, adjusted based on slider input.

--- runtime: shiny output: html_document ---  ```{r} library(rmarkdown); library(ggvis); library(shiny);  sliderinput("sliderdays", "days forward 1/1/2014: ", min=0, max=45, value=1, step=1)  graphdate = reactive({as.date("2014-01-01") + input$sliderdays}) renderprint(graphdate())  ``` 

however, if replace graphdate = reactive({as.date("2014-01-01") + input$sliderdays})

startdate <- as.date("2014-04-01") graphdate <- reactive({startdate + input$sliderdays}) 

then output of renderprint(graphdate()) goes

1 "2014-04-01" [this changes on slider input, date]

to

character(0)

i don't understand why startdate have created , used inside graphdate reactive function, opposed defined right above , referenced in reactive function, work.enter image description here

sessioninfo() ## r version 3.2.0 (2015-04-16) ## platform: i386-w64-mingw32/i386 (32-bit) ## running under: windows 7 x64 (build 7601) service pack 1 ##  ## locale: ## [1] lc_collate=english_united states.1252  ## [2] lc_ctype=english_united states.1252    ## [3] lc_monetary=english_united states.1252 ## [4] lc_numeric=c                           ## [5] lc_time=english_united states.1252     ##  ## attached base packages: ## [1] stats     graphics  grdevices utils     datasets  methods   base      ##  ## other attached packages: ## [1] dt_0.0.52         shiny_0.12.0      knitr_1.10.5      ggvis_0.4.1.9000  ## [5] rmarkdown_0.6.2.2 ##  ## loaded via namespace (and not attached): ##  [1] rcpp_0.11.6      digest_0.6.8     dplyr_0.4.1      assertthat_0.1   ##  [5] mime_0.3         r6_2.0.1         xtable_1.7-4     jsonlite_0.9.16  ##  [9] dbi_0.3.1        formatr_1.2      magrittr_1.5     evaluate_0.7     ## [13] stringi_0.4-1    rstudioapi_0.3.1 tools_3.2.0      stringr_1.0.0    ## [17] htmlwidgets_0.4  yaml_2.1.13      httpuv_1.3.2     parallel_3.2.0   ## [21] htmltools_0.2.6 

seems work me. did understand question right?

enter image description here

version info , session info:

enter image description here enter image description here enter image description here


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -