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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With