R
From HPC
(→Example R Program) |
(→Running R program on HPC) |
||
Line 47: | Line 47: | ||
#$ -N R_JOB | #$ -N R_JOB | ||
#$ -V -cwd | #$ -V -cwd | ||
- | R CMD BATCH | + | R CMD BATCH myrscript myrscript.out |
Submitting job | Submitting job |
Revision as of 16:16, 2 March 2009
R is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&T, now Lucent Technologies) by John Chambers and colleagues. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, ...) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.
One of R's strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.
Website: http://www.r-project.org/
Contents |
Documentation/Tutorials
Main R Project Wiki
http://wiki.r-project.org/rwiki/doku.php
Moving from Stata to R
http://wiki.r-project.org/rwiki/doku.php
Packages Installed
- arm
- zoo
- coda
- stats
- sna
The are other packages may already be installed. If you require other packages to please contact the cluster administrators.
Other packages are listed at http://cran.r-project.org/web/packages/
Running R program from file
R CMD BATCH rscriptfile outputfile
Example
R CMD BATCH myrscript myrscript.out
Your results will be saved to a file called myrscript.out
Running R program on HPC
Example job script saved as myrjob
#!/bin/bash #$ -N R_JOB #$ -V -cwd R CMD BATCH myrscript myrscript.out
Submitting job
qsub myrjob
Example R Program
Save the following to a file called myrscript to work with example instructions for running R jobs.
library("sna") library("network") # These are the names of the actors labels <- c("Allison", "Drew", "Ross", "Sarah", "Eliot", "Keith") net <- network.initialize(6) # Label the verticies net %v% "vertex.names" <- labels # Data on page 123. add.edges(net, c(1,1,2,2,5,6,3,4), c(2,3,4,5,2,3,4,2)) degree(net, cmode="outdegree") degree(net, cmode="indegree") # Note that the variance of indegree and outdegree, on page 128, can be calculated with: var(degree(net, cmode="outdegree")) var(degree(net, cmode="indegree"))