NiklausMeier / HB_CE_microsimulation

R code for Hemophilia B cost-effectiveness microsimulation
GNU General Public License v3.0
1 stars 0 forks source link

The Working directories setting problem #1

Open peikolim opened 1 month ago

peikolim commented 1 month ago

I try to run this code, but R prompts an error that Error in file(filename, "r", encoding = encoding) : cannot open the connection In addition: Warning message: In file(filename, "r", encoding = encoding) : cannot open file './functions/fun_model_setup.R': No such file or directory why this error be prompts? I ran it exactly according to your code https://github.com/NiklausMeier/HB_CE_microsimulation/blame/1d8301f4697b8861d9d297f3e4c9fa5906b6cace/00_master_file.R#L115

peikolim commented 1 month ago

I'm new in bulid a microsimulation model in R, thanks for anwsering my question!!!

NiklausMeier commented 1 month ago

Hello Peikolim

This sounds as though we need to make sure you have the correct directory in R specified, which will also be crucial for the rest of the code to function.

When we run source(paste0(directories$dir_fun, "fun_model_setup.R")) we are pasting in the directory we specified earlier in the code. We try to load in the function from the repository's function folder: _./functions/fun_modelsetup.R

However, this assume your directory has already been set to be at HB_CE_microsimulation. If you enter the getwd() function, it should point you there. In my case, getwd() gives me the following directory: "C:/Users/min1/OneDrive - Berner Fachhochschule/Rprojects/HB_CE_microsimulation". But for you, this will be a different directory.

One way to make sure you have the right directory would be open the entire project via the "HB_CE_microsimulation.Rproj" file, which should automatically set the correct directory to wherever you have locally saved this repository.

I hope this helps!