Following this answer I'm trying to create an app that will output a plot based on the value I will pass to the app via URL
library(shiny)
shinyApp(
ui = fluidPage(
mainPanel(
plotOutput("plot")
)
),
server = function(input, output, session) {
observe({
query <- parseQueryString(session$clientData$url_search)
if (!is.null(query[['text']])) {
n <- query[['text']]
}
})
output$plot <- renderPlot({
# Add a little noise to the cars data
plot(cars[sample(nrow(cars), n), ])
})
}
)
Yet I don't know where/how I should store/pass the value of the variable n
so to transfer it from observe()
to renderPlot()
.