Roberta Pappadà (rpappada@units.it)
February 2024
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
The Four RStudio Windows:
type 1+2 into the console and press Enter!
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")
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 openxlsx.
, start R and type
install.packages("openxlsx")
In RStudio you can use “Install” from the Packages tab. Then type the command
library(openxlsx)
You can also click the box next to the package name.
Manuals available from the web page of CRAN (The Comprehensive R Archive Network: 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)