Difference between revisions of "Programming/R"

From HPC
Jump to: navigation , search
m
m
Line 23: Line 23:
 
</pre>
 
</pre>
  
==== Modules Available ====
+
====Modules Available====
  
 
The following modules are available:
 
The following modules are available:
Line 29: Line 29:
 
* module add R/3.3.0
 
* module add R/3.3.0
  
 +
====Batch Mode====
  
  
==== Compilation ====
+
<pre style="background-color: black; color: white; border: 2px solid black; font-family: monospace, sans-serif;">
 +
 
 +
[username@login01 ~]$  module add R/3.3.0
 +
[username@login01 ~]$  Rscript myprogram.rsc
 +
 
 +
"Hello World"
 +
 
 +
</pre>
 +
 
 +
 
 +
====Compilation====
  
 
The program is interpreted by the R runtime program, so compilation does not apply here.
 
The program is interpreted by the R runtime program, so compilation does not apply here.
  
===== Interactive Mode =====
+
=====Interactive Mode=====
  
 
<pre style="background-color: black; color: white; 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;">
Line 64: Line 75:
 
</pre>
 
</pre>
  
=====Libraries=====
+
====Libraries====
  
 
To show the libraries included type ( ''within R'' ) the command : '''library()'''
 
To show the libraries included type ( ''within R'' ) the command : '''library()'''
Line 91: Line 102:
 
</pre>
 
</pre>
  
=====Installing Additional Libraries=====
+
====Installing Additional Libraries====
 
 
 
 
===== Batch Mode =====
 
 
 
 
 
<pre style="background-color: black; color: white; border: 2px solid black; font-family: monospace, sans-serif;">
 
 
 
[username@login01 ~]$  module add R/3.3.0
 
[username@login01 ~]$  Rscript myprogram.rsc
 
  
"Hello World"
 
  
</pre>
 
  
 
== Further Information ==
 
== Further Information ==

Revision as of 08:40, 12 April 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 add R/3.3.0

Batch Mode


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

"Hello World"


Compilation

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

Interactive Mode

[username@login01 ~]$ module add 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.

>

Libraries

To show the libraries included type ( within R ) the command : library()


Packages in library ‘/trinity/clustervision/CentOS/7/apps/R/3.3.0/lib64/R/library’:

base                    The R Base Package
boot                    Bootstrap Functions (Originally by Angelo Canty
                        for S)
class                   Functions for Classification
cluster                 "Finding Groups in Data": Cluster Analysis
                        Extended Rousseeuw et al.
codetools               Code Analysis Tools for R
colorspace              Color Space Manipulation
compiler                The R Compiler Package
datasets                The R Datasets Package
dichromat               Color Schemes for Dichromats
digest                  Create Compact Hash Digests of R Objects
foreign                 Read Data Stored by Minitab, S, SAS, SPSS,
                        Stata, Systat, Weka, dBase, ...
ggplot2                 Create Elegant Data Visualisations Using the
                        Grammar of Graphics

Installing Additional Libraries

Further Information

Icon home.png