Last active
February 15, 2018 03:04
-
-
Save keqiang/b69c49c95fc9b9108285e52b1a78bca3 to your computer and use it in GitHub Desktop.
Example of using 'shinywidgets' package to import data to R Shiny app
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(shinywidgets) # install by devtools::install_github("keqiang/shinywidgets") | |
ui <- fluidPage( | |
wellPanel( | |
dataTableImportWidget("tableImport1"), | |
verbatimTextOutput("debug") | |
) | |
) | |
server <- function(input, output) { | |
importedData <- importDataTable("tableImport1") | |
output$debug <- renderPrint({ | |
print(importedData()) | |
}) | |
} | |
shinyApp(ui = ui, server = server) |
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(shinydashboard) | |
library(shinywidgets) # install by devtools::install_github("keqiang/shinywidgets") | |
ui <- dashboardPage( | |
dashboardHeader(title = "Table Importing Example"), | |
dashboardSidebar(), | |
dashboardBody( | |
fluidRow( | |
box(title = "Data Import", | |
status = "primary", | |
solidHeader = TRUE, | |
width = 12, | |
dataTableImportWidget("tableImport1"), | |
verbatimTextOutput("debug") | |
) | |
) | |
) | |
) | |
server <- function(input, output) { | |
# the return value is the imported data table as a data frame(tibble) | |
importedData <- importDataTable("tableImport1") | |
output$debug <- renderPrint({ | |
print(importedData()) | |
}) | |
} | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment