A question posted at
Can you help please to rewrite the following code (from
https://shiny.rstudio.com/articles/action-buttons.html) into RMarkdown?
# Codes from https://shiny.rstudio.com/articles/action-buttons.html
library(shiny)
ui <- fluidPage(
# Pattern 1 - Command
tags$head(tags$script(src = "message-handler.js")),
actionButton("do", "Click Me"),
hr(),
# Pattern 2 - Delay reactions
actionButton("go", "Go"),
numericInput("n", "n", 50),
plotOutput("plot2"),
)
server <- function(input, output, session) {
# Pattern 1 - Command
observeEvent(input$do, {
session$sendCustomMessage(type = 'testmessage',
message = 'Thank you for clicking')
} )
# Pattern 2 - Delay reactions
randomVals <- eventReactive(input$go, {
runif(input$n)
})
output$plot2 <- renderPlot({
hist(randomVals())
})
}
shinyApp(ui, server)