ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Introduction to R
Dott.ssa Paola Pozzolo
sos.unistat@gmail.com
Asti, 24/06/2019
R developers: Ross Ihaka and Robert Gentleman
Introduction to statistical software R
What is ?
Why don’t everybody use ?
5
Introduction to statistical software R
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.
Installing R
• R Homepage: http://www.r-project.org/
• CRAN for Italian download: https://cran.stat.unipd.it/
R Console
R Studio
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
Common mistakes in R programming
Data operators
Data analysis in R: an example
R data structures
The workspace
It is your current R working
environment and includes any
user-defined objects (vectors,
matrices, data frames, lists,
functions).
R Reference Card https://cran.r-project.org/doc/contrib/Short-refcard.pdf
R Commander
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
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
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
How to save?
iii. Save R workspace: R will save 2 files: .Rdata and .Rhistory
Now it’s your turn...
23
E-mail me at sos.unistat@gmail.com

More Related Content

Introduction to statistical software R

  • 1. Introduction to R Dott.ssa Paola Pozzolo sos.unistat@gmail.com Asti, 24/06/2019
  • 2. R developers: Ross Ihaka and Robert Gentleman
  • 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
  • 12. Common mistakes in R programming
  • 14. Data analysis in R: an example
  • 16. The workspace It is your current R working environment and includes any user-defined objects (vectors, matrices, data frames, lists, functions).
  • 17. R Reference Card https://cran.r-project.org/doc/contrib/Short-refcard.pdf
  • 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