Skip to content

Instantly share code, notes, and snippets.

@gadenbuie
Created April 24, 2018 13:14
Show Gist options
  • Save gadenbuie/080893583cbe099721ea80a84e2c1d9e to your computer and use it in GitHub Desktop.
Save gadenbuie/080893583cbe099721ea80a84e2c1d9e to your computer and use it in GitHub Desktop.
A basic miniUI Shiny gadget
#' 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