Question

I have a shiny app where server.r including the following code

shinyServer(function(input, output) {

  data <- reactive(function() {
   # some processing
   df # dataframe with columns: name,date,count 
 })

  output$plot1 <- reactivePlot(function() {
   # boxplot based on df$count grouped by df$name
 })

 output$plot2 <- reactivePlot(function() {
   # linegraph based on x=df$date, y=df$count grouped by df$name
 })
})     

How do I construct it so that I can reference in the reactivePlots the df$count etc. I have created in the reactive function , 'data'

cheers

Was it helpful?

Solution

Use data()$count. The () is how you retrieve a reactive function's value, and the fact that you can see data from within the two reactive plot functions is just a natural consequence of R's scoping rules.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top