Skip to content

Instantly share code, notes, and snippets.

@keqiang
Last active February 15, 2018 03:04
Show Gist options
  • Save keqiang/b69c49c95fc9b9108285e52b1a78bca3 to your computer and use it in GitHub Desktop.
Save keqiang/b69c49c95fc9b9108285e52b1a78bca3 to your computer and use it in GitHub Desktop.
Example of using 'shinywidgets' package to import data to R Shiny app
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)
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