if (interactive()) {
library(shiny)
library(shinyscreenshot)
shinyApp(
ui = fluidPage(
h1("{shinyscreenshot} demo"),
numericInput("num", "Number of points", 50),
plotOutput("plot"),
actionButton("screenshot1", "Capture entire page"),
actionButton("screenshot2", "Capture plot")
),
server = function(input, output) {
observeEvent(input$screenshot1, {
screenshot()
})
observeEvent(input$screenshot2, {
screenshot(id = "plot")
})
output$plot <- renderPlot({
plot(runif(input$num))
})
}
)
}
Run the code above in your browser using DataLab