R is implemented from a command line interface as seen in Figure 24. If you are an experienced
programmer, you may even cringe at some of the constructs used in R. Don't worry, it just works.
User input occurs at the “>” prompt and the R interpreter responds with the results. A single result is
preceded by a [1] to indicate the response number. The “;” character is used to add comment
information that the R interpreter ignores.
The R workspace includes a single command line interface window and a separate graphics window for
displaying plots. “RStudio” is free software package that provides a more versatile interface to the R
interpreter. RStudio is available at www.rstudio.com
6.2.2 Introduction to R Commands
R recognizes basic math operators, such as +,-,*, and /. Assignments are made using “<-”. For
example:
> 2+2
[1] 4
> a<-2+2
;assign “a” the result of 2+2
> a
[1] 4
In the above example, 'a' was assigned the value '4' and can be used later. R works with vectors and
matrices as well.
> b<-c(1,2,3)
;”c” is a function call that creates a vector
> b
[1] 1 2 3
> a*b
[1] 4 8 12
Gulf Coast Data Concepts
Page 26
X16-1D, Rev B
Figure 25: RStudio Interface