Skip to content

Instantly share code, notes, and snippets.

@edgararuiz-zz
Created April 10, 2018 21:28
Show Gist options
  • Save edgararuiz-zz/becbbbf70d870f6ce18682fac0f846ca to your computer and use it in GitHub Desktop.
Save edgararuiz-zz/becbbbf70d870f6ce18682fac0f846ca to your computer and use it in GitHub Desktop.
library(dplyr)
library(dbplyr)
library(DT)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Quick Example"),
dashboardSidebar(selectInput("select", "Selection", c("one", "two"))),
dashboardBody(
tabsetPanel(
id = "tabs",
tabPanel(
title = "Dashboard",
value = "page1",
dataTableOutput("monthly")
)
)
)
)
server <- function(input, output, session) {
output$monthly <- renderDataTable(datatable(mtcars))
observeEvent(input$monthly_cell_clicked, {
cell <- input$monthly_cell_clicked
sr <- mtcars$mpg[cell$row]
appendTab(
inputId = "tabs",
tabPanel(
sr,
renderDataTable(
mtcars %>%
filter(mpg == mtcars$mpg[cell$row]),
rownames = FALSE)
)
)
updateTabsetPanel(session, "tabs", selected = as.character(sr))
})
}
shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment