Last active
February 5, 2023 07:14
-
-
Save vnijs/2e6eec27eaea12beec00 to your computer and use it in GitHub Desktop.
Example of selectize drag-and-drop in Shiny 0.12.2.9000 or higher
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(shiny) | |
library(DT) | |
dat <- mtcars | |
shinyServer(function(input, output, session) { | |
output$ui_view_vars <- renderUI({ | |
vars <- colnames(dat) | |
## using selectizeInput with drag_drop and DT | |
selectizeInput("view_vars", "Select variables to show:", choices = vars, | |
selected = vars, multiple = TRUE, | |
options = list(plugins = list('remove_button', 'drag_drop'))) | |
}) | |
output$dataviewer <- DT::renderDataTable({ | |
if (is.null(input$view_vars)) return() | |
DT::datatable(dat[,input$view_vars]) | |
}) | |
}) |
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
shinyUI(fluidPage( | |
sidebarLayout( | |
sidebarPanel( | |
uiOutput("ui_view_vars") | |
), | |
mainPanel( | |
tabPanel("View", DT::dataTableOutput("dataviewer")) | |
) | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment