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, ...

Get The Definitive ANTLR 4 Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.