# Syntax

##### Operator Syntax and Precedence

Outlines R syntax and gives the precedence of operators.

- Keywords
- programming, documentation

##### Details

The following unary and binary operators are defined. They are listed in precedence groups, from highest to lowest.

`:: :::` |

access variables in a namespace |

`$ @` |

component / slot extraction |

`[ [[` |

indexing |

`^` |

exponentiation (right to left) |

`- +` |

unary minus and plus |

`:` |

sequence operator |

`%any%` |

special operators (including `%%` and `%/%` ) |

`* /` |

multiply, divide |

`+ -` |

(binary) add, subtract |

`< > <=>= == !=` |

ordering and comparison |

`!` |

negation |

`& &&` |

and |

`| ||` |

or |

`~` |

as in formulae |

`-> ->>` |

rightwards assignment |

`<- <<-< code="">` |

assignment (right to left) |

`=` |

assignment (right to left) |

`?` |

help (unary and binary) |

`=`

is not
necessarily an operator.) The binary operators `::`

, `:::`

, `$`

and `@`

require
names or string constants on the right hand side, and the first two
also require them on the left.

The links in the **See Also** section cover most other aspects of
the basic syntax.

##### Note

There are substantial precedence differences between R and S. In
particular, in S `?`

has the same precedence as (binary) `+ -`

and `& && | ||`

have equal precedence.

##### References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
*The New S Language*.
Wadsworth & Brooks/Cole.

##### See Also

`Arithmetic`

, `Comparison`

, `Control`

,
`Extract`

, `Logic`

,
`NumericConstants`

, `Paren`

,
`Quotes`

, `Reserved`

.

The ‘R Language Definition’ manual.

*Documentation reproduced from package base, version 3.1.3, License: Part of R 3.1.3*