Skip to content

Commit 3cc830e

Browse files
Merge pull request #374 from hpcleuven/feature/R_devtools
Feature/r devtools
2 parents d23e0f9 + e02fd0d commit 3cc830e

File tree

3 files changed

+95
-11
lines changed

3 files changed

+95
-11
lines changed

source/software/r_devtools.rst

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
.. _r_devtools:
2+
3+
Installing R packages with devtools
4+
===================================
5+
6+
Introduction
7+
~~~~~~~~~~~~
8+
9+
The installation of some R packages may require the use of devtools.
10+
Devtools is an R package that facilitates the installation of other
11+
R packages from github, gitlab, bitbucket or other repositories.
12+
In what follows github will be used as an example. Please consult the
13+
devtools_ documentation for examples of other repositories.
14+
15+
Depending on how your R library is managed, you will need a slightly different
16+
approach to use and install devtools.
17+
18+
.. note::
19+
20+
When consulting the devtools documentation, make sure that it is the correct version!
21+
It should match the devtools version included in the R module. To check which devtools version is installed:
22+
23+
.. code-block:: r
24+
25+
library(devtools)
26+
sessioninfo::session_info()
27+
28+
Installing in a local R library
29+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30+
31+
If you manage your R packages in a :ref:`local R library<r_package_management_standard_lib>` under ``$VSC_DATA/R``
32+
while using a centrally installed R module, you can use the devtools package included in the module.
33+
You will need to execute the following commands in the R console:
34+
35+
.. code-block:: r
36+
37+
> # First check that the R library path points to your local R library:
38+
> .libPaths()
39+
> # Set the R library path if this is not the case.
40+
> .libPaths("/data/leuven/XXX/vscXXXXX/R/")
41+
> # Load devtools and e.g. install your package from github:
42+
> library(devtools)
43+
> devtools::install_github("Developer/Package")
44+
45+
.. note::
46+
47+
The devtools package is **not** included in "-bare" R modules, e.g. R/4.0.2-foss-2018a-bare.
48+
49+
Installing in a conda environment
50+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51+
52+
If you are using conda to manage your R packages, you should first install
53+
devtools in your conda environment. The following steps assume that you
54+
already have a conda environment named "science". If you do not yet have
55+
a conda environment, First create a :ref:`conda environment<r_package_management_conda>`.
56+
In the following example, it is assumed that your miniconda environment is installed in ``$VSC_DATA/miniconda3``.
57+
58+
.. code-block:: bash
59+
60+
$ # Activate your conda environment and install devtools
61+
$ source activate science
62+
$ conda install -c conda-forge r-devtools
63+
$ # Launch R
64+
$ R
65+
66+
.. code-block:: r
67+
68+
> # Check that the R library path points to your conda R library
69+
> .libPaths()
70+
> # Set the R library path if this was not the case.
71+
> .libPaths("/data/leuven/XXX/vscXXXXX/miniconda3/envs/science/lib/R/library")
72+
> # Load devtools and e.g. install your package from github:
73+
> library(devtools)
74+
> devtools::install_github("Developer/Package")
75+
76+
.. _devtools: https://www.rdocumentation.org/packages/devtools

source/software/r_package_management.rst

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
.. _R_package_management:
2+
13
R package management
24
====================
35

46
Introduction
57
------------
68

7-
Most of the useful R packages come in the form of packages that can be
8-
installed separately. Some of those are part of the default installation
9-
on VSC infrastructure. Given the astounding number of packages, it is
10-
not sustainable to install each and everyone system wide. Since it is
11-
very easy for a user to install them just for himself, or for his
12-
research group, that is not a problem though. Do not hesitate to contact
13-
support whenever you encounter trouble doing so.
9+
Most of the useful R packages can be installed separately. Some of those are
10+
part of the centrally installed R modules. However, given the astounding number of
11+
packages, it is not sustainable to install each and everyone of them system wide.
12+
Fortunately, it is very easy for users to install R packages themselves.
13+
If you do encounter problems when doing so, do not hesitate to contact support.
14+
15+
.. _r_package_management_standard_lib:
1416

1517
Standard R package installation
1618
-------------------------------
@@ -45,8 +47,12 @@ library, .e.g., ::
4547

4648
$ module load GSL/2.5-GCC-6.4.0-2.28
4749

48-
Note that R packages often depend on the specific R version they were installed
49-
for, so you may need to reinstall them for other versions of R.
50+
.. note::
51+
52+
R packages often depend on the specific R version they were installed
53+
for, so you may need to reinstall them for other versions of R.
54+
55+
.. _r_package_management_conda:
5056

5157
Installing R packages using conda
5258
---------------------------------
@@ -176,4 +182,6 @@ original state, use the following command
176182
More information
177183
~~~~~~~~~~~~~~~~
178184

179-
Additional information about conda can be found on its `documentation site <https://conda.readthedocs.io/en/latest/>`__.
185+
Additional information about conda can be found on its `documentation site <https://docs.conda.io/en/latest/>`__.
186+
187+
For installing R packages from github or other repositories see also :ref:`R devtools<r_devtools>`:

source/software/software_development.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ Libraries
3939
perl_package_management
4040
python_package_management
4141
r_package_management
42-
42+
r_devtools

0 commit comments

Comments
 (0)