software:r:farber

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
software:r:farber [2018-04-26 13:20] – [R libraries and extensions] sraskarsoftware:r:farber [2019-08-30 15:11] anita
Line 245: Line 245:
  
 === Using IT's udbuild environment === === Using IT's udbuild environment ===
-IT developed a formalization for installing modules called [[farber:udbuild]]+IT developed a formalization for installing modules called [[/abstract/farber/install_software|udbuild]]
 which can simplify the installation of modules.  Here is an example ''udbuild'' which can simplify the installation of modules.  Here is an example ''udbuild''
 script which can be used to install a personal R library. script which can be used to install a personal R library.
Line 287: Line 287:
 This script will attempt to build the cuda capable R modules using the This script will attempt to build the cuda capable R modules using the
 cuda 6.5 version into ''$WORKDIR/sw/r/add-ons/r3.1.1/testing/default-cuda-6.5''. cuda 6.5 version into ''$WORKDIR/sw/r/add-ons/r3.1.1/testing/default-cuda-6.5''.
 +
 +====== R script in batch ======
 +
 +==== matmul.R script ====
 +
 +Consider the simple R script file to multiply a small 3x3 matrix
 +
 +<file R matmul.R>
 +# Calculate and print small matrix AA'
 +a <- matrix(1:12,3,4);
 +a%*%t(a)
 +</file>
 +
 +Let's test this R script using ''Rscript'' from the command line on a compute node.  Don't forget to set your [[general/userguide/04_compute_environ?&#using-workgroup-and-directories|workgroup]] to define your cluster group or //investing-entity// compute nodes before you use ''qlogin'' to get on a compute node. For example,
 +
 +<code bash>
 +workgroup -g it_css
 +qlogin
 +vpkg_require r/3
 +Rscript matmul.R
 +</code>
 +
 +The output to the screen:
 +
 +<code>
 +     [,1] [,2] [,3]
 +[1,]  166  188  210
 +[2,]  188  214  240
 +[3,]  210  240  270
 +</code>
 +
 +To return to the head node, type
 +<code bash>
 +exit
 +</code>
 +
 +==== matmul.qs file ====
 +
 +To run a R script in batch instead of on the command line has nearly the same steps.
 +Consider the queue submission script file:
 +
 +<file matmul.qs>
 +#$ -N matmultiply
 +
 +# Add vpkg_require commands after this line:
 +vpkg_require r/3
 +
 +# Syntax: Rscript [options] filename.R [arguments]
 +Rscript matmul.R 
 +</file>
 +
 +Now to run the R script simply submit the job from the head node with the
 +''qsub'' command.
 +
 +<code>
 +qsub matmul.qs
 +</code>
 +
 +You should see a notification that your job was submitted.  Something like this
 +
 +<code bash>
 +Your job 2283886 ("matmultiply") has been submitted
 +</code>
 +
 +After the code completes the output of the script will appear in the file
 +''matmultiply.o2283886'' because ''-N matmultiply'' defines the name of the job in ''matmul.qs'' and appears in the notification above as ''("matmultiply")'' with ''2283886'' assigned as the job ID. Type 
 +
 +<code>
 +more matmultiply.o2283886
 +</code>
 +
 +to display the contents of the output file on the screen.  For example,
 +
 +<code>
 +Adding dependency `x11/RHEL6.1` to your environment
 +Adding package `r/3.0.2` to your environment
 +     [,1] [,2] [,3]
 +[1,]  166  188  210
 +[2,]  188  214  240
 +[3,]  210  240  270
 +</code>
  
  
  • software/r/farber.txt
  • Last modified: 2021-03-17 14:44
  • by anita