|
| 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 |
0 commit comments