Difference between revisions of "Programming/R"

From HPC
Jump to: navigation , search
m
m
Line 36: Line 36:
 
===== Interactive Mode =====
 
===== Interactive Mode =====
  
<pre style="background-color: #C8C8C8; color: black; border: 2px solid black; font-family: monospace, sans-serif;">
+
<pre style="background-color: black; color: white; border: 2px solid black; font-family: monospace, sans-serif;">
  
module load R/3.3.0
+
[username@login01 ~]$ module load R/3.3.0
R
+
[username@login01 ~]$ R
  
 
R version 3.3.0 (2016-05-03) -- "Supposedly Educational"
 
R version 3.3.0 (2016-05-03) -- "Supposedly Educational"
Line 66: Line 66:
 
===== Batch Mode =====
 
===== Batch Mode =====
  
<pre style="background-color: #C8C8C8; color: black; border: 2px solid black; font-family: monospace, sans-serif;">
 
  
module load R/3.3.0
+
<pre style="background-color: black; color: white; border: 2px solid black; font-family: monospace, sans-serif;">
Rscript myprogram.rsc
+
 
 +
[username@login01 ~]$  module load R/3.3.0
 +
[username@login01 ~]$  Rscript myprogram.rsc
  
 
"Hello World"
 
"Hello World"
R
 
  
 
</pre>
 
</pre>

Revision as of 14:11, 3 February 2017

Programming Details

R is a programming language and software environment for statistical analysis, graphics representation and reporting.

R is freely available under the GNU General Public License, and can be loaded as a module on Viper (with Linux), Windows (PC) and Mac.


Programming example


x <- c(151, 174, 138, 186, 128, 136, 179, 163, 152, 131)
y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48)

# Apply the lm() function.
relation <- lm(y~x)

print(relation)


Modules Available

The following modules are available:

  • module load R/3.3.0


Compilation

The program is interpreted by the R runtime program, so compilation does not apply here.

Interactive Mode

[username@login01 ~]$ module load R/3.3.0
[username@login01 ~]$ R

R version 3.3.0 (2016-05-03) -- "Supposedly Educational"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

>


Batch Mode

[username@login01 ~]$  module load R/3.3.0
[username@login01 ~]$  Rscript myprogram.rsc

"Hello World"