r - ggplot and rshiny plot is not refreshed -


i have output plot dependent on reactive function called datasetinput. whenever change input variable output function updates, plot see on client not end changing. output data used ggplot generate plot , data changing. i'm not sure whats going on.

datasetinput <- reactive({         data <- input$globaldata     table <- c()     ...     table })  output$plot <- renderplot({         table <- datasetinput()        cat('32hr: ',unlist(table[which(table$group=='32hr'),3]),'\n')          cat('24hr: ',unlist(table[which(table$group=='24hr'),3]),'\n')          range <- max(table$centroiddistances.rg) - min(table$centroiddistances.rg)     cat('range: ',range,'\n')     plot <- ggplot(table,aes(x=table$centroiddistances.rg,fill=table$group)) +          geom_histogram(aes(y=..density..),pos="dodge") +         geom_density(alpha=0.2)     print(plot) },height=300,width=600) 

i have not seen problem before, how can client change output when output$plot changes (is specific problem ggplot?)

this problem appears fixed setting environment = environment() within ggplot:

ggplot(table,aes(x=table$centroiddistances.rg,fill=table$group),environment=environment()) +    geom_histogram(aes(y=..density..),pos="dodge",binwidth=range/30,minx=0,width=600) +   geom_density(alpha=0.2) 

not sure why fixes things, including environment setting makes graph update expected on client side.


Comments