I'm trying to learn how to use shiny modules to simplify a messy shiny app I have. The app currently reads in several data sets using a list of names like this:
dataSetsToLoad <- c("set1name", "set2name", "etc")
for (i in 1:length(dataSetsToLoad) {
dt <- readRDS(paste0(dataSetsToLoad[i], ".RDS")
assign(dataSetsToLoad[i], dt)
}
These end up in the global environment and are accessible to all my non-modularized code.
Following a code pattern from here, I'd like to modify the above to something like the following
stash = reactiveValues()
for (i in 1:length(dataSetsToLoad) {
stashVar <- paste0("stash$", dataSetsToLoad[i])
dt <- readRDS(paste0(dataSetsToLoad[i], ".RDS")
assign(stashVar, dt)
}
The summary question is how do I put the dt into the stash reactive with the dynamically created name in stashVar. A second question is whether there is any way to test this without actually running it in a shiny app.
save(df2, df1, file = "data.RData"). Did you know you can do something like this? You can easily save and load multiple data.frames in one RData File.