R language: Introduction

R is a computer programming language and environment focused on statistics and graphics.

Install R in linux



In Debian Sid we can install R using packaging system:
$ sudo aptitude install r-base r-base-dev

Accept this solution? [Y/n/q/?] y
The following NEW packages will be installed:
cdbs{a} cpp-5{a} gcc-5{a} gfortran{a} gfortran-5{a} libasan2{a}
libcc1-0{a} libgcc-5-dev{a} libgfortran-5-dev{a} libisl15{a} libmpx0{a}
libncurses5-dev{a} libpcre3-dev{a} libpcre32-3{a} libpcrecpp0v5{a}
libreadline-dev{a} libreadline6-dev{a} libtinfo-dev{a} r-base
r-base-core{a} r-base-dev r-base-html{a} r-cran-boot{a} r-cran-class{a}
r-cran-cluster{a} r-cran-codetools{a} r-cran-foreign{a}
r-cran-kernsmooth{a} r-cran-lattice{a} r-cran-mass{a} r-cran-matrix{a}
r-cran-mgcv{a} r-cran-nlme{a} r-cran-nnet{a} r-cran-rpart{a}
r-cran-spatial{a} r-cran-survival{a} r-doc-html{a} r-recommended{a}

Launch R interpreter

$ R

R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
Copyright (C) 2015 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.

> prompt appears.
# creates comments until the end of the line.

We can run some demos:
> demo() # list all available demos.

Run recursion demo:
> demo(recursion)

Show some help:
> help()

Quit the session:
> quit()
> q()

R interactive help

help.start function launches a local web server and opens a web browser session showing R documentation.
> help.start()

Invoke interactive help in prompt

> help(solve)


> ?solve

If feature has special characters or is a reserver keyword it needs quotes around:
> help("[[")
> help("if")

Search for help

> help.search("solve")
> ??solve

R documentation

R manuals


You can also browse this documentation locally using help.start() command.


R (programming language - Wikipedia)