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.