Professional Documents
Culture Documents
Basics R PDF
Basics R PDF
Basics R PDF
What is R?
● Language for Statistical Computing
● Open-source implementation of S
● Statistical Techniques
● Visualization Capabilities
● Highly extensible
Introduction to R
Advantages
● Open source! free!
● Master at graphics
● Command-line interface
● R packages: extensions of R
● Vibrant community
Introduction to R
Disadvantages
● Easy to learn, hard to master
RDocumentation.org
Introduction to R
Console
Introduction to R
Console
> 1 + 2
[1] 3
> 2
[1] 2
Introduction to R
Variables
● Store a variable to reuse later
● <-
> height
[1] 2
> width
[1] 4
Introduction to R
Workspace
> ls()
[1] "height" "width"
> depth
Error: object 'depth' not found
> ls()
[1] "area" "height" "width"
Introduction to R
R script
● Text file with R commands
! rectangle.R
height <- 2
width <- 4
area <- height * width
area
Introduction to R
R script
! rectangle.R
height <- 2
width <- 4
area <- height * width
area
> area
[1] 8
Introduction to R
R script
! rectangle.R
height <- 3
width <- 6
area <- height * width
area
> area
[1] 18
Introduction to R
Comments #
! rectangle.R
Workspace (2)
> ls()
[1] "area" "height" "width"
> rm(area)
> ls()
[1] "height" "width"
> area
Error: object 'area' not found
INTRODUCTION TO R
Let’s practice!