© Thomas Mailund 2017

Thomas Mailund, Metaprogramming in R, 10.1007/978-1-4842-2881-4_4

4. Manipulating Expressions

Thomas Mailund

(1)Aarhus N, Denmark

Expressions, the kind you create using the quote function , come in four flavors: a primitive value, a name, a function call or a control structure, and a pairlist. Function calls include operators such as the arithmetic or logical operators because these are function calls as well in R, and control structures can be considered just a special kind of function calls—they only really differ from function calls in the syntax you use to invoke them.

class(quote(1))## [1] "numeric"class(quote("foo"))## [1] "character"class(quote(TRUE))## [1] "logical"class(quote(x))## [1] "name"class(quote(f(x)))## [1] ...

Get Metaprogramming in R: Advanced Statistical Programming for Data Science, Analysis and Finance now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.