Contents
How to get path of current script Stack Overflow?
Once established, the root directory doesn’t change during the active R session. here () then appends the arguments to the root directory. The development version of the here package is available on github. Based on Alexis Lucattini and user2554330 answers, to make it work on both command line and RStudio.
How to set the library path in Bash?
I tried it using export LD_LIBRARY_PATH=$ (pwd)/lib/ Although bash allows you to set and export a variable in a single statement, not all shells do, so the two step approach is more portable, if that’s a concern.
How to change default library path on Ubuntu?
On Ubuntu, the recommended way of changing the default library path for a user, is to set the R_LIBS_USER variable in the ~/.Renviron file. If your default package library has been changed after installing a new version of R or by any other means, you can append both the libraries to use all the packages with the help of the commands below.
What is the LD LIBRARY PATH variable used for?
LD_LIBRARY_PATH is an environment variable that is used to set paths to shared libraries (that is.so files) so that it available during execution of executables.
How to get the size of the source directory?
The idea is to get the size of the source directory with your build tool and just add it to the __FILE__ macro, removing the directory entirely and only showing the file name starting at your source directory.
How to get the path to the file?
In RStudio, you can get the path to the file currently shown in the source pane using If you want the name of the file that’s been run by source (filename), that’s a little harder. You need to look for the variable srcfile somewhere back in the stack.
How to find the source of a RStudio file?
The following solves the problem for three cases: RStudio source Button, RStudio R console ( source (…), if the file is still in the Source pane) or the OS console via Rscript: The following code gives the directory of the running Rscript if you are running it either from Rstudio or from the command line using Rscript command: