#' import_data UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
#' @import shinydashboard
#' @import shiny
#'
mod_import_data_ui <- function(id){
ns <- NS(id)
tagList(
shiny::sidebarLayout(
shiny::sidebarPanel(
shiny::fileInput(inputId = ns("file1")
, "Choose a CSV file",
multiple = FALSE,
accept = c("text/csv",
"text/comma-separated-values, text/plain",
".csv"),
buttonLabel = "Searching...")
),
shiny::mainPanel(
DT::dataTableOutput(ns('data_table'))
)
)
)
}
#' import_data Server Functions
#'
#' @noRd
#' @import DT
#' @import tools
mod_import_data_server <- function(id){
moduleServer(id, function(input, output, session){
ns <- session$ns
options(shiny.maxRequestSize=30*1024^2)
output$data_table <- DT::renderDataTable({ ## Importa archivo CSV y excel
req(input$file1) # Requiere el archivo subido
tryCatch(
{
data_1 = read.csv(input$file1$datapath)
},
error = function(e){
stop(safeError(e))
}
)
DT::datatable(data_1,
filter = 'top', extensions = c('Buttons', 'Scroller'),
options = list(scrollY = 650,
scrollX = 500,
deferRender = TRUE,
scroller = TRUE,
buttons = list('excel',
list(extend = 'colvis',
targets = 0,
visible = FALSE)),
dom = 'lBfrtip',
fixedColumns = TRUE),
rownames = FALSE)
})
})
}
## To be copied in the UI
# mod_import_data_ui("import_data_ui_1")
## To be copied in the server
# mod_import_data_server("import_data_ui_1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.