How shiny load my local data


#1

Hi ,

may I ask how shiny load my data. suppose run #daily. R got and save a new_data.RData.
does it mean shiny app will load it every time when some one visit my site ? Am I doing it right ?

#daily. R
save.image("new_data.RData")

#ui.R
load("new_data.RData")

#server.R
load("new_data.RData")

#2

If you are running daily.R from your shiny apps working directory and it is being saved into that folder than your load(...) functions will load whatever the most recent version of the file is everytime the app is started. If it is being saved somewhere else on your computer or if you app is being hosted somewhere else than you may run into some issues as the data will have to be in the app’s working directory.


#3

Hi ,Tyler ,Thanks a lot for your reply. actually its more like a efficiency question.
I got my app running fine now. But if 100 people visit my site each day. dose it mean the shinyapp will load(“new_data.RData”) 100 times or once the app run . it only load it one time? and “new_data.RData” is quite big like 1 million rows. dont know I understand it correctly ?


#4

The data will be loaded at the start of every session, so it would be loaded 100 times if the app is visited 100 separate times throughout the day.

You may want to consider moving from an .RData file to a database.

You can check out dbplyr here which makes working with databases in R more convenient