I created a R script that automate some data processing tasks and I wish to share it with others coworkers without knowledge of R. The idea is to create a zip file with R and the script where the user will insert the data in a specific folder and then just run a batch script that will call Rscript in CMD and run the routine.
The problem is I don’t know where they will extract the zip so the program can be in any folder. Some people could extract it in a disk C others in disk D and in any possible folder.
I already figured out a way of calling the script using a batch file because once I put the batch script in the root of the project I can get the directory using %~dp0
and from it I can find any path that I need.
The problem is how I will load libraries inside the R script if I don’t know where the library folder will be? If I knew at least where it would be I could use something like this.path::here()
to the directory inside R.
At first I thought about writting the path with batch and the load it in r, but I din’t find a way to read it into r since I wouldn’t know the exact path from where it will come.