Reset reactive value on Shiny

1,834 views
Skip to first unread message

Carlos Sánchez

unread,
Sep 15, 2014, 6:35:53 AM9/15/14
to shiny-...@googlegroups.com
Hi,

I have a reactive value which comes from a Highcharts (rCharts) plot

a <- hPlot(freq ~ topics5,
               data = getChart(datos()),
               type = 'column',
               group = 'topics15',
               group.na = 'NA\'s')
    a$set(dom = 'chart')
    a$plotOptions(column = list(stacking = "normal",
                                cursor = 'pointer',
                                point = list(events = list(click =
                                                             "#! function() {
                                                           Shiny.onInputChange('click', {
                                                              topic: this.name + '-' + this.series.name
                                                           })
                                                           } !#"))))

I use this input$click$topic to filter some data which I present in a renderDataTable. Everything works fine but I would also like to be able to reset this value.

I would like to implement the following pseudo-code but all my attempts have failed miserably :(

miTopic <- reactiveValues(var = NULL)

observe(
  if (button != pressed)
    miTopic$var = input$click$topic
  else
    miTopic$var = NULL
)

Any ideas?

Carlos

    

Joe Cheng

unread,
Sep 15, 2014, 12:03:31 PM9/15/14
to Carlos Sánchez, shiny-...@googlegroups.com
What's "button != pressed"? Is that like an actionButton that you'd like to use to reset the value? If so, you want something more like this:

miTopic <- reactiveValues(var = NULL)

observe({
  miTopic$var <- input$click$topic
})
observe({
  if (input$resetButton == 0) return()
  miTopic$var <- NULL
})



Carlos

    

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/dcf27895-1a6c-4a1e-bc58-f03570fe9919%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carlos Sánchez

unread,
Sep 15, 2014, 12:24:05 PM9/15/14
to shiny-...@googlegroups.com

That did the trick :)

Thanks!

Carlos
Reply all
Reply to author
Forward
0 new messages