Created
April 24, 2018 13:14
-
-
Save gadenbuie/080893583cbe099721ea80a84e2c1d9e to your computer and use it in GitHub Desktop.
A basic miniUI Shiny gadget
This file contains hidden or 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
#' Basic miniUI Gadget Function | |
#' | |
#' Single view with button row along the bottom | |
basic_miniUI_gadget <- function() { | |
require(shiny) | |
require(miniUI) | |
ui <- miniPage( | |
gadgetTitleBar("Shiny gadget example"), | |
miniContentPanel( | |
padding = 0, | |
plotOutput("histogram") | |
), | |
miniButtonBlock( | |
actionButton("reset", "Rerun") | |
) | |
) | |
server <- function(input, output, session) { | |
output$histogram <- renderPlot({ | |
require(ggplot2) | |
ggplot(sim_dat(), aes(x)) + geom_histogram() | |
}) | |
sim_dat <- reactiveVal(data.frame(x = rnorm(100))) | |
observeEvent(input$reset, { | |
sim_dat(data.frame(x = rnorm(100))) | |
}) | |
observeEvent(input$done, { | |
stopApp(TRUE) | |
}) | |
} | |
runGadget(ui, server, viewer = paneViewer()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment