| Line 1... |
Line 1... |
| 1 |
% File src/library/base/man/sum.Rd
|
1 |
% File src/library/base/man/sum.Rd
|
| 2 |
% Part of the R package, https://www.R-project.org
|
2 |
% Part of the R package, https://www.R-project.org
|
| 3 |
% Copyright 1995-2015 R Core Team
|
3 |
% Copyright 1995-2018 R Core Team
|
| 4 |
% Distributed under GPL 2 or later
|
4 |
% Distributed under GPL 2 or later
|
| 5 |
|
5 |
|
| 6 |
\name{sum}
|
6 |
\name{sum}
|
| 7 |
\alias{sum}
|
7 |
\alias{sum}
|
| 8 |
\title{Sum of Vector Elements}
|
8 |
\title{Sum of Vector Elements}
|
| Line 17... |
Line 17... |
| 17 |
\item{\dots}{numeric or complex or logical vectors.}
|
17 |
\item{\dots}{numeric or complex or logical vectors.}
|
| 18 |
\item{na.rm}{logical. Should missing values (including \code{NaN}) be
|
18 |
\item{na.rm}{logical. Should missing values (including \code{NaN}) be
|
| 19 |
removed?}
|
19 |
removed?}
|
| 20 |
}
|
20 |
}
|
| 21 |
\value{
|
21 |
\value{
|
| 22 |
The sum. If all of \code{\dots} are of type integer or logical, then
|
22 |
The sum. If all of the \eqn{M} \code{\dots} arguments are of type
|
| 23 |
the sum is integer, and in that case the result will be \code{NA} (with a
|
23 |
integer or logical, then the sum is \code{\link{integer}} when
|
| - |
|
24 |
possible and is \code{double} otherwise. Integer overflow should no
|
| - |
|
25 |
longer happen since \R version 3.5.0.
|
| 24 |
warning) if integer overflow occurs. Otherwise it is a length-one
|
26 |
For other argument types it is a length-one numeric
|
| 25 |
numeric or complex vector.
|
27 |
(\code{\link{double}}) or complex vector.
|
| 26 |
|
28 |
|
| 27 |
\strong{NB:} the sum of an empty set is zero, by definition.
|
29 |
\strong{NB:} the sum of an empty set is zero, by definition.
|
| 28 |
}
|
30 |
}
|
| 29 |
\details{
|
31 |
\details{
|
| 30 |
This is a generic function: methods can be defined for it
|
32 |
This is a generic function: methods can be defined for it
|
| Line 41... |
Line 43... |
| 41 |
were \code{integer(0)}.
|
43 |
were \code{integer(0)}.
|
| 42 |
|
44 |
|
| 43 |
Loss of accuracy can occur when summing values of different signs:
|
45 |
Loss of accuracy can occur when summing values of different signs:
|
| 44 |
this can even occur for sufficiently long integer inputs if the
|
46 |
this can even occur for sufficiently long integer inputs if the
|
| 45 |
partial sums would cause integer overflow. Where possible
|
47 |
partial sums would cause integer overflow. Where possible
|
| 46 |
extended-precision accumulators are used, but this is
|
48 |
extended-precision accumulators are used, typically well supported
|
| 47 |
platform-dependent.
|
49 |
with C99 and newer, but possibly platform-dependent.
|
| 48 |
}
|
50 |
}
|
| 49 |
\section{S4 methods}{
|
51 |
\section{S4 methods}{
|
| 50 |
This is part of the S4 \code{\link[=S4groupGeneric]{Summary}}
|
52 |
This is part of the S4 \code{\link[=S4groupGeneric]{Summary}}
|
| 51 |
group generic. Methods for it must use the signature
|
53 |
group generic. Methods for it must use the signature
|
| 52 |
\code{x, \dots, na.rm}.
|
54 |
\code{x, \dots, na.rm}.
|