diff --git a/source/software/r_devtools.rst b/source/software/r_devtools.rst new file mode 100644 index 000000000..4d2918bf3 --- /dev/null +++ b/source/software/r_devtools.rst @@ -0,0 +1,76 @@ +.. _r_devtools: + +Installing R packages with devtools +=================================== + +Introduction +~~~~~~~~~~~~ + +The installation of some R packages may require the use of devtools. +Devtools is an R package that facilitates the installation of other +R packages from github, gitlab, bitbucket or other repositories. +In what follows github will be used as an example. Please consult the +devtools_ documentation for examples of other repositories. + +Depending on how your R library is managed, you will need a slightly different +approach to use and install devtools. + +.. note:: + + When consulting the devtools documentation, make sure that it is the correct version! + It should match the devtools version included in the R module. To check which devtools version is installed: + + .. code-block:: r + + library(devtools) + sessioninfo::session_info() + +Installing in a local R library +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you manage your R packages in a :ref:`local R library` under ``$VSC_DATA/R`` +while using a centrally installed R module, you can use the devtools package included in the module. +You will need to execute the following commands in the R console: + +.. code-block:: r + + > # First check that the R library path points to your local R library: + > .libPaths() + > # Set the R library path if this is not the case. + > .libPaths("/data/leuven/XXX/vscXXXXX/R/") + > # Load devtools and e.g. install your package from github: + > library(devtools) + > devtools::install_github("Developer/Package") + +.. note:: + + The devtools package is **not** included in "-bare" R modules, e.g. R/4.0.2-foss-2018a-bare. + +Installing in a conda environment +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you are using conda to manage your R packages, you should first install +devtools in your conda environment. The following steps assume that you +already have a conda environment named "science". If you do not yet have +a conda environment, First create a :ref:`conda environment`. +In the following example, it is assumed that your miniconda environment is installed in ``$VSC_DATA/miniconda3``. + +.. code-block:: bash + + $ # Activate your conda environment and install devtools + $ source activate science + $ conda install -c conda-forge r-devtools + $ # Launch R + $ R + +.. code-block:: r + + > # Check that the R library path points to your conda R library + > .libPaths() + > # Set the R library path if this was not the case. + > .libPaths("/data/leuven/XXX/vscXXXXX/miniconda3/envs/science/lib/R/library") + > # Load devtools and e.g. install your package from github: + > library(devtools) + > devtools::install_github("Developer/Package") + +.. _devtools: https://www.rdocumentation.org/packages/devtools diff --git a/source/software/r_package_management.rst b/source/software/r_package_management.rst index 882fb0551..98d8b512e 100644 --- a/source/software/r_package_management.rst +++ b/source/software/r_package_management.rst @@ -1,16 +1,18 @@ +.. _R_package_management: + R package management ==================== Introduction ------------ -Most of the useful R packages come in the form of packages that can be -installed separately. Some of those are part of the default installation -on VSC infrastructure. Given the astounding number of packages, it is -not sustainable to install each and everyone system wide. Since it is -very easy for a user to install them just for himself, or for his -research group, that is not a problem though. Do not hesitate to contact -support whenever you encounter trouble doing so. +Most of the useful R packages can be installed separately. Some of those are +part of the centrally installed R modules. However, given the astounding number of +packages, it is not sustainable to install each and everyone of them system wide. +Fortunately, it is very easy for users to install R packages themselves. +If you do encounter problems when doing so, do not hesitate to contact support. + +.. _r_package_management_standard_lib: Standard R package installation ------------------------------- @@ -45,8 +47,12 @@ library, .e.g., :: $ module load GSL/2.5-GCC-6.4.0-2.28 -Note that R packages often depend on the specific R version they were installed -for, so you may need to reinstall them for other versions of R. +.. note:: + + R packages often depend on the specific R version they were installed + for, so you may need to reinstall them for other versions of R. + +.. _r_package_management_conda: Installing R packages using conda --------------------------------- @@ -176,4 +182,6 @@ original state, use the following command More information ~~~~~~~~~~~~~~~~ -Additional information about conda can be found on its `documentation site `__. +Additional information about conda can be found on its `documentation site `__. + +For installing R packages from github or other repositories see also :ref:`R devtools`: diff --git a/source/software/software_development.rst b/source/software/software_development.rst index 35f296165..fb8da1104 100644 --- a/source/software/software_development.rst +++ b/source/software/software_development.rst @@ -39,4 +39,4 @@ Libraries perl_package_management python_package_management r_package_management - + r_devtools