Created
January 17, 2020 10:49
-
-
Save rfaelens/a37898ec1614a0751fbd0a763d25dc59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plotly) | |
library(ggplot2) | |
ui <- fluidPage( | |
column(6, | |
checkboxInput("go_table", label="Render table", value=TRUE), | |
tableOutput("table") | |
), | |
column(6, | |
checkboxInput("go_plot", label="Render plot", value=TRUE), | |
plotlyOutput("plot") | |
) | |
) | |
server <- function(input, output, session) { | |
output$table <- snapshotPreprocessOutput( | |
renderTable({ | |
shiny::req(input$go_table) #induce a silent.error if input$go is FALSE | |
data.frame(x=rnorm(5), y=runif(5)) | |
}), function(x) { | |
XML::readHTMLTable(x) #snapshot as table contents | |
}) | |
output$plot <- renderPlotly({ | |
shiny::req(input$go_plot) #induce a silent.error if input$go is FALSE | |
ggplot(data.frame(x=rnorm(1000))) + | |
geom_histogram(aes(x=x)) | |
}) | |
} | |
shinyApp(ui=ui, server=server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment