R Language Tutorial
R is a mathematical programming language designed for mathematical researchers, mainly used for statistical analysis, plotting, and data mining.
If you are a beginner in computer programming and eager to learn general-purpose programming, R is not an ideal choice; you can choose Python、C or Java。
Both R and C are products of Bell Labs, but they focus on different areas. R is an interpreted language aimed at mathematical researchers, while C was designed for computer software engineers.
R is an interpreted language (unlike C, which is compiled), and it runs much slower than C, which is not conducive to optimization. However, it provides richer data structure operations at the syntax level and makes it very convenient to output text and graphics, so it is widely used in mathematics, especially statistics.
Official R website:https://cran.r-project.org/
List of official mirror sites:https://cran.r-project.org/mirrors.html
Who should read this tutorial?
This tutorial is designed specifically for software programmers who need to learn R from scratch.
If you are a very experienced R user, you can still use this tutorial as a syntax reference, but the tutorial itself may not contain material that solves your deeper problems.
Features of R
- The R environment is GNU open-source software, with good compatibility and free to use
- Its syntax is well suited to complex mathematical operations
- Rich data types, including common data structures such as vectors, matrices, factors, and data sets
- Good code style and strong readability
Although R is mainly used for statistical analysis or developing statistics-related software, some people use it for matrix computation. Its analysis speed is comparable to GNU Octave, a free software dedicated to matrix computation, and to the commercial software MATLAB.
Compiling/executing R programs
Example (helloworld.R)
myString
<-
"Hello, World!"
(
myString
)
Run Example »
R files use the .R extension; you can use the command-line tool Rscript to execute R script files.
Execute the above script:
Rscript helloworld.R
References
-
Official R website:https://cran.r-project.org/
-
R language manual:https://cran.r-project.org/manuals.html