Actions

Difference between revisions of "R"

From Montana Tech High Performance Computing

Line 1: Line 1:
The R package for statistical computing and graphics is installed on the system. Version 3.4.3 installed from source code is available and installed in <code>/opt/R/R-3.4.3</code>. To access it:
+
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:
  
: <code>module load R/3.4.3</code>
+
: <code>module load R</code>
  
An example job script, might look something like:
+
===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:
  
: <code style=display:block>#!/bin/sh<br>#PBS -l nodes=1:ppn=32<br>#PBS -N PingJob<br>#PBS -m e<br>#PBS -M username@mtech.edu<br>#PBS -l walltime=00:01:00<br><br>cd $PBS_O_WORKDIR<br>module load R/3.4.3<br>R < parLapply_test.R > parLapply_test.output --no-save</code>
+
:<code style=display:block>module load R<br>R</code>
 +
 
 +
Then you can use the <code>install.packages</code> command inside R to install a package. For example,
 +
:<code style=display:block>> install.packages("ggplot2")</code>
 +
Because you don't have a write permission in the /opt directory, where R is installed, R will throw the following warings:
 +
:<code style=display:block>Warning in install.packages("ggplot2") :<br>   'lib = "/opt/ohpc/pub/libs/gnu8/R/3.6.1/lib64/R/library"' is not writable<br>Would you like to use a personal library instead? (yes/No/cancel)</code>
 +
Answer <code>yes</code>, R will then ask you to create a library folder in your own directory:
 +
:<code style=display:block>Would you like to create a personal library<br>‘~/R/x86_64-pc-linux-gnu-library/3.6’<br>to install packages into? (yes/No/cancel)</code>
 +
Answer <code>yes</code> again, R will start the installation process.

Revision as of 09:51, 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.