Introduction to R
Roberta Pappadà
April 1, 2026
R is a free software environment for statistical analysis and graphics:
R Studio is a open source integrated development environment for R
-> Obtain R via the Comprehensive R Archive Network (CRAN):

-> RStudio:
www.rstudio.com/products/rstudio/download/
Instructions for software installation are available at
To open RStudio, simply double-click the RStudio icon on your desktop
The Four RStudio Windows:
collect the code into the R Script, then run selection with
Control + Enter on Windows
'#' for comments
character :
"a"
numeric:
2, 5.2
integer:
2L
logical:
TRUE,FALSE
complex:
2+4i
What kind of object is it?
Vector
Matrix
Array
List
Factor
Data frame
c( ), vector( ), seq( )
matrix( )
array()
list()
factor()
data.frame()
Use plot( ) to produce a scatter plot
x<-c(0.5, 0.5, 2, 4, 6, 0.2, 5, 4.1)
y<-c(0.5, 1.5, 3.2, 8, 6, 1.2, 3, 3.5)
plot(x,y, pch=21, bg="red")
plot of chunk unnamed-chunk-1
R packages for basic functions are already available when R is installed.
Other packages can be obtained from CRAN and its mirrors. For example, to install the forecast package, start R and type
install.packages("quantmod")
In RStudio you can use “Install” from the Packages tab. Then type the command
library(quantmod)
You can also click the box next to the package name.
R CRAN page https://cran.r-project.org/
IcebreakeR by Andrew Robinson, 2016 (.pdf)
Data Camp – Free course (link to course)
Hands-On Programming with R by Garrett Grolemund (website)