Each plot uses the slider value to generate random numbers. However,
rnorm
once. sliderInput(inputId = "num1", label = "Sample size", value = 25, min = 1, max = 100) ## Both plots get different data!! ## rnorm has been executed twice! renderPlot({ x = rnorm(input$num1) plot(x) }) renderPlot({ x = rnorm(input$num1) plot(x) })
Create a reactive
object that each plot can access.
x = reactive(rnorm(input$num1)) renderPlot({plot(x())}) renderPlot({plot(x())})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.