| 42333 |
ripley |
1 |
% File src/library/base/man/Syntax.Rd
|
|
|
2 |
% Part of the R package, http://www.R-project.org
|
| 59616 |
ripley |
3 |
% Copyright 1995-2012 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 59616 |
ripley |
6 |
% = is treated specially in the parser: see PR#14595
|
|
|
7 |
|
| 18286 |
ripley |
8 |
\name{Syntax}
|
| 56186 |
murdoch |
9 |
\alias{Syntax}
|
| 34966 |
maechler |
10 |
\title{Operator Syntax and Precedence}
|
| 18286 |
ripley |
11 |
\description{
|
| 59616 |
ripley |
12 |
Outlines \R syntax and gives the precedence of operators.
|
| 18286 |
ripley |
13 |
}
|
|
|
14 |
\details{
|
|
|
15 |
The following unary and binary operators are defined. They are listed
|
|
|
16 |
in precedence groups, from highest to lowest.
|
|
|
17 |
\tabular{ll}{
|
| 56382 |
murdoch |
18 |
\code{:: :::}\tab access variables in a namespace\cr
|
| 21048 |
ripley |
19 |
\code{$ @}\tab component / slot extraction\cr
|
| 51163 |
murdoch |
20 |
\code{[ [[}\tab indexing\cr
|
| 18286 |
ripley |
21 |
\code{^}\tab exponentiation (right to left)\cr
|
|
|
22 |
\code{- +}\tab unary minus and plus\cr
|
|
|
23 |
\code{:}\tab sequence operator\cr
|
| 58042 |
ripley |
24 |
\code{\%any\%}\tab special operators (including \code{\%\%} and \code{\%/\%})\cr
|
| 18286 |
ripley |
25 |
\code{* /}\tab multiply, divide\cr
|
| 18347 |
ripley |
26 |
\code{+ -}\tab (binary) add, subtract\cr
|
| 18286 |
ripley |
27 |
\code{< > <= >= == !=}\tab ordering and comparison\cr
|
|
|
28 |
\code{!}\tab negation\cr
|
|
|
29 |
\code{& &&}\tab and\cr
|
|
|
30 |
\code{| ||}\tab or\cr
|
|
|
31 |
\code{~}\tab as in formulae\cr
|
|
|
32 |
\code{-> ->>}\tab rightwards assignment\cr
|
| 59616 |
ripley |
33 |
\code{<- <<-}\tab assignment (right to left)\cr
|
| 18286 |
ripley |
34 |
\code{=}\tab assignment (right to left)\cr
|
|
|
35 |
\code{?}\tab help (unary and binary)\cr
|
|
|
36 |
}
|
|
|
37 |
Within an expression operators of equal precedence are evaluated
|
| 59616 |
ripley |
38 |
from left to right except where indicated. (Note that \code{=} is not
|
|
|
39 |
necessarily an operator.)
|
| 57685 |
maechler |
40 |
|
| 51163 |
murdoch |
41 |
The binary operators \code{::}, \code{:::}, \code{$} and \code{@} require
|
|
|
42 |
names or string constants on the right hand side, and the first two
|
|
|
43 |
also require them on the left.
|
| 18286 |
ripley |
44 |
|
| 42950 |
ripley |
45 |
The links in the \bold{See Also} section cover most other aspects of
|
| 18286 |
ripley |
46 |
the basic syntax.
|
|
|
47 |
}
|
|
|
48 |
\note{
|
|
|
49 |
There are substantial precedence differences between \R and S. In
|
| 35579 |
ripley |
50 |
particular, in S \code{?} has the same precedence as (binary) \code{+ -}
|
|
|
51 |
and \code{& && | ||} have equal precedence.
|
| 18286 |
ripley |
52 |
}
|
| 24300 |
ripley |
53 |
\references{
|
|
|
54 |
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
|
|
|
55 |
\emph{The New S Language}.
|
| 47262 |
ripley |
56 |
Wadsworth & Brooks/Cole.
|
| 24300 |
ripley |
57 |
}
|
| 18286 |
ripley |
58 |
\seealso{
|
|
|
59 |
\code{\link{Arithmetic}}, \code{\link{Comparison}}, \code{\link{Control}},
|
| 34712 |
ripley |
60 |
\code{\link{Extract}}, \code{\link{Logic}},
|
| 42950 |
ripley |
61 |
\code{\link{NumericConstants}}, \code{\link{Paren}},
|
|
|
62 |
\code{\link{Quotes}}, \code{\link{Reserved}}.
|
| 18286 |
ripley |
63 |
|
| 61823 |
ripley |
64 |
The \sQuote{R Language Definition} manual.
|
| 18286 |
ripley |
65 |
}
|
|
|
66 |
\keyword{documentation}
|
| 43772 |
maechler |
67 |
\keyword{programming}
|