R in Palmetto#
Learning objectives
Questions:
How to run R scripts in Palmetto
Objectives:
Learn how to run R in Palmetto
Learn how to install R packages in Palmetto
Keypoints:
Rscript
Palmetto access
If you need to process a large amount of data and you think your laptop/desktop is not fast enough, you can utilize the power of the Palmetto supercomputing cluster. If you have an account on Palmetto, you can log in as described in our manual.
Let’s request a compute node:
qsub -I -l select=1:ncpus=4:mem=32gb:interconnect=fdr,walltime=2:00:00
In order to run R, you will first need to load the R module. We have several versions of R installed on Palmetto, most recent being 4.0.3:
module load r/4.0.5-gcc/9.5.0
We can now open R in interactive mode (text-only console). Let’s install a package
doParallel
:
R
> install.packages("doParallel")
To quit the R console, type
quit()
. Let’s create a simple script and run it. We can use the text editor callednano
:
nano randmatrix.r
This will open a text editor. Let’s paste these lines which create a random 4x4 matrix (to paste, Mac users can use Cmd+V, and PC users can use Shift+Ins):
M <- matrix(rnorm(16), nrow=4)
M
Let’s save it by pressing
Ctrl+O
, thenEnter
, thenCtrl+X
. We can run this script with theRScript
command:
Rscript randmatrix.r
If you want to use RStudio on Palmetto, you can use OpenOnDemand interface – please see our manual.