'How to efficiently read large sas data sets in Rshiny

I build a big shiny with so many modules, and I used many observe function in each panel. I found that it spent so much time when this shiny app is setup and read all sas datasets. I think this beacuse all observe function will be run every time when shiny app is setup. I want to know how can I reduce speed when shiny app set up. Thanks so much!!!!!!!

The code which reads sas datasets as below:

study_data <- list()
  for(i in 1 : length(folder)){
    file.list <- list.files(path=paste0('./project/',folder[i],'/'),pattern = ".sas7bdat")
    rawdata <- list()
    for(j in 1 : length(file.list)){
      rawdata[[j]] <- read_sas(paste0("./project/",folder[i],"/",file.list[j]))
      names(rawdata)[j] <- strsplit(file.list[j],split = ".sas7bdat",fixed = T)[[1]]
    }

    study_data[[i]] <- rawdata
    names(study_data)[i] <- folder[i]
  }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source