Difference between revisions of "R"
From Montana Tech High Performance Computing
(→Install R Packages) |
|||
Line 5: | Line 5: | ||
===Install R Packages=== | ===Install R Packages=== | ||
Generally, if you need to use R packages that are not available, you can always install it locally in your account. | Generally, if you need to use R packages that are not available, you can always install it locally in your account. | ||
+ | |||
First start an R session: | First start an R session: | ||
Line 18: | Line 19: | ||
In addition, you can also install R packages in a different folder other than the default one. For example, to install a package at <code>~/libs/R_libs</code>: | In addition, you can also install R packages in a different folder other than the default one. For example, to install a package at <code>~/libs/R_libs</code>: | ||
+ | |||
First create the directory: | First create the directory: | ||
:<code style=display:block>mkdir ~/libs/R_libs</code> | :<code style=display:block>mkdir ~/libs/R_libs</code> | ||
Then inside R: | Then inside R: | ||
:<code style=display:block>> install.packages("ggplot2", lib="~/libs/R_libs")</code> | :<code style=display:block>> install.packages("ggplot2", lib="~/libs/R_libs")</code> |
Revision as of 08:59, 28 May 2020
The R package for statistical computing and graphics is installed on the system. Version 3.6.1 installed with the gnu8 toolchain. To access it:
-
module load R
Install R Packages
Generally, if you need to use R packages that are not available, you can always install it locally in your account.
First start an R session:
module load R
R
Then you can use the install.packages
command inside R to install a package. For example,
> install.packages("ggplot2")
Because you don't have a write permission in the /opt directory, where R is installed, R will throw the following warings:
Warning in install.packages("ggplot2") :
'lib = "/opt/ohpc/pub/libs/gnu8/R/3.6.1/lib64/R/library"' is not writable
Would you like to use a personal library instead? (yes/No/cancel)
Answer yes
, R will then ask you to create a library folder in your own directory:
Would you like to create a personal library
‘~/R/x86_64-pc-linux-gnu-library/3.6’
to install packages into? (yes/No/cancel)
Answer yes
again, R will start the installation process.
In addition, you can also install R packages in a different folder other than the default one. For example, to install a package at ~/libs/R_libs
:
First create the directory:
mkdir ~/libs/R_libs
Then inside R:
> install.packages("ggplot2", lib="~/libs/R_libs")