R Language Arithmetic Operators


Nearly all operators in R are really functions. For example, + is a function defined as function (e1, e2) .Primitive("+") where e1 is the left-hand side of the operator and e2 is the right-hand side of the operator. This means it is possible to accomplish rather counterintuitive effects by masking the + in base with a user defined function.

For example:

`+` <- function(e1, e2) {e1-e2}

> 3+10
[1] -7