I’m using a Shinylive application to analyze some datasets, and I’m noticing that at some point, the dataset is too large to load into Shinylive (e.g., a 100mb won’t load), although it is fine in a regular Shiny application.
I can’t find any documentation on the Shinylive GitHub repos that explain what the file size limitations are for loading data into Shinylive applications.
Are there any clear rules on what the file size constraints are? I imagine it may vary by browser, but it would be good to know for the popular browsers like Chrome, Firefox, and Edge.
As an example, here is a simple Shiny application that lets the user select a CSV file, read it into R, and then produce a table of counts from a selected variable.
library(shiny)
options(shiny.maxRequestSize = 1000*(1024^2))
# Define UI for application
ui <- fluidPage(
# Application title
titlePanel("Load Data, Compute Counts"),
# Sidebar to select input data file
sidebarLayout(
sidebarPanel(
fileInput(
"datafile",
"Choose Data File",
multiple = FALSE,
accept = c(
".csv"
)
),
uiOutput("var_selector")
),
# Show a table of counts for a selected variable
mainPanel(
tableOutput("analysis_results")
)
)
)
# Define server logic required to load data, produce counts
server <- function(input, output) {
analysis_data <- reactive({
if (!is.null(input$datafile)) {
if (endsWith(input$datafile[['datapath']], "csv")) {
readr::read_csv(input$datafile[['datapath']])
}
}
})
output$var_selector <- renderUI({
if (!is.null(analysis_data())) {
data_variables <- colnames(analysis_data())
selectInput("analysis_var",
"Select analysis variable",
data_variables,
multiple = FALSE,
selected = NULL)
}
})
output$analysis_results <- shiny::renderTable({
if (!is.null(analysis_data()) && !is.null(input$analysis_var)) {
analysis_data() |>
dplyr::count(!!rlang::sym(input$analysis_var))
}
})
}
# Run the application
shinyApp(ui = ui, server = server)
The app can be exported to a Shinylive application and then run using the following R code:
shinylive::export(".", "shinylive-app")
httpuv::runStaticServer("shinylive-app")