This document provides an introduction to R, including what R is, how to install and use it, common mistakes, and data structures. It discusses that R was created by Ross Ihaka and Robert Gentleman and contains over 10,000 user-developed packages on topics like statistics, graphics, and data analysis. It also provides instructions on installing R from its homepage or a Italian download site, using the R console and R Studio interfaces, the workspace environment, and saving workspaces to preserve data between sessions.
7. R Packages
The «base» R system contains the base package,
which contains the most fundamental functions.
Over 10,000 other packages are available on CRAN
developed by users and programmers around the world.
8. Installing R
• R Homepage: http://www.r-project.org/
• CRAN for Italian download: https://cran.stat.unipd.it/
11. Working with R
• R is a case-sensitive language (mydata differ from Mydata)
• Commands are entered interactively at the R user prompt. Up and
down arrow keys scroll through your command history.
• Objects are assigned values using : object <- function(par1, par2, …)
• If you specify a new value for an object again, R will forget what value
it had before.
• Comments are preceded by the # symbol
19. How to install R Commander?
 Write in R console:
install.packages("Rcmdr", dependencies=TRUE)
OR
 From the menu: Packages | Install package… ïƒ Rcmdr
19
How to load R Commander?
 From the menu: Packages ïƒ Load packages ïƒ Rcmdr
OR
 Write in R console:
library(Rcmdr)
If you accidently close the Rcmdr window, type Commander() in the R Console and hit OK
20. R Commander interface
20
Script window
shows most
recent commands
or code
Output window
shows results
from most recent
commands
Message window
reports errors
from commands
Menu system has
many commonly
used diagnostics
and tests
21. When you quit R …
Save R workspace in order to save your data in the R format.
Save also your output and your commands. It’s essential if you want to re-run the analyses later.
R have no knowledge of previous packages loaded: load the package at the start of each R session .
21
22. How to save?
iii. Save R workspace: R will save 2 files: .Rdata and .Rhistory
23. Now it’s your turn...
23
E-mail me at sos.unistat@gmail.com