Reactive execution example (code)

ui <- fluidPage(
  numericInput("a", "Range mid point", value = 10),
  numericInput("b", "Sample size", value = 1),
  numericInput("c", "Times sample size", value = 1),
  br(),
  h4("Sampled data from the range"),
  plotOutput("x"),
  h4("Highest number in the sampled data"),
  tableOutput("y"),
  h4("Times sample size"),
  textOutput("z")
)

server <- function(input, output, session) {
  rng <- reactive(input$a * 2)
  smp <- reactive(sample(rng(), input$b, replace = TRUE))
  bc <- reactive(input$b * input$c)
  
  output$x <- renderPlot(hist(smp()))
  output$y <- renderTable(max(smp()))
  output$z <- renderText(bc())
}