Shiny modules : reactive values do not update

28 views
Skip to first unread message

Sam

unread,
Apr 10, 2018, 1:14:19 AM4/10/18
to Shiny - Web Framework for R
Hi,

I am trying to use Shiny modules with a reactive value as parameter. 

here is a simple example. The first plot is shown but when I click on the button to update the value of the reactive variable, the plot doesn't update.

Here is the code : 


library(shiny)


linkedScatterUI
<- function(id) {
  ns
<- NS(id)
 
  fluidRow
(
    column
(6, plotOutput(ns("plot1")))
 
)
}


linkedScatter
<- function(input, output, session, data) {
 
  dataWithSelection
<- reactive({
    data
 
})
 
  output$plot1
<- renderPlot({
     scatterPlot
(data)
 
})
 


 
return(dataWithSelection)
}




scatterPlot
<- function(data) {
 plot
(data)
}




ui
<- fixedPage(
  actionButton
("test", "Increment"),
  linkedScatterUI
("scatters")
)






server
<- function(input, output, session) {
 
  rv
<- reactiveValues(test = 1)
 
 callModule
(linkedScatter, "scatters", rv$test)
 
  observeEvent
(input$test,{
    rv$test
<- -rv$test
   
})
}


shinyApp
(ui, server)


I don't know how to make it work.

Thanks for your help

Reply all
Reply to author
Forward
0 new messages