## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

## Parsing R

R is an expressive domain-specific programming language for describing statistical problems. For example, it’s easy to create vectors, apply functions to them, and filter them (shown here using the R interactive shell).

 ​=> ​ x <- seq(1,10,.5) # x = 1, 1.5, 2, 2.5, 3, 3.5, ..., 10​ ​=> ​ y <- 1:5 # y = 1, 2, 3, 4, 5​ ​=> ​ z <- c(9,6,2,10,-4) # z = 9, 6, 2, 10, -4​ ​=> ​ y + z # add two vectors​ ​<= [1] 10 8 5 14 1 # result is 1-dimensional vector ​=> ​ z[z<5] # all elements in z < 5​ ​<= [1] 2 -4 ​=> ​ mean(z) # compute the mean of vector z​ ​<= [1] 4.6 ​=> ​ zero <- function() { return(0) }​ ​=> ​ zero()​ ​<= [1] 0

R is a medium-sized but complicated programming language, and most or all of us have a handicap: we don’t know R. That means we ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required