Redundand ui.R and server.R Parameter and Performance



original, I needed to read the "my" Data only in server.R:

myData<- read.csv(file="../data/....")

Then I adapted the application in the way, that the line:

myData<- read.csv(file="../data/....")

is placed in third file: parameter.R and I also referenced:

source("./parameter.r", local=T) in both: in ui.R and in server.R.

The reason is: I need the same consistent calculated variables in both: in ui.R and in server.R. E.g.:

myData<- read.csv(file="../data/....")
period_end_date= max(myData$days);   
period_start_date= min(myData$days);   
the_period= as.numeric(period_end_date) - as.numeric(period_start_date)

i am afraid that the performance will suffer, when the csv- file become very big.

Or it is really not so? I mean that reading and keeping the file in memory, then the calculation of the same variables take place not really twice?

Thank you for your opinion in advance.

Regards, Peter


If you create a third script named global.R and read the csv file in this script then it will be available by default in both your server and ui code without having to source it. That is assuming it is saved into the same repo as the ui.R and server.R.