24 Contributors: 5 Tuesday, September 13, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial:
Roadmap: roadmap

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

Related Examples