Created
April 10, 2018 21:28
-
-
Save edgararuiz-zz/becbbbf70d870f6ce18682fac0f846ca 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(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