EVOLUTION-MANAGER
Edit File: sum.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Sum of Vector Elements</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for sum {base}"><tr><td>sum {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Sum of Vector Elements</h2> <h3>Description</h3> <p><code>sum</code> returns the sum of all the values present in its arguments. </p> <h3>Usage</h3> <pre> sum(..., na.rm = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>numeric or complex or logical vectors.</p> </td></tr> <tr valign="top"><td><code>na.rm</code></td> <td> <p>logical. Should missing values (including <code>NaN</code>) be removed?</p> </td></tr> </table> <h3>Details</h3> <p>This is a generic function: methods can be defined for it directly or via the <code><a href="groupGeneric.html">Summary</a></code> group generic. For this to work properly, the arguments <code>...</code> should be unnamed, and dispatch is on the first argument. </p> <p>If <code>na.rm</code> is <code>FALSE</code> an <code>NA</code> or <code>NaN</code> value in any of the arguments will cause a value of <code>NA</code> or <code>NaN</code> to be returned, otherwise <code>NA</code> and <code>NaN</code> values are ignored. </p> <p>Logical true values are regarded as one, false values as zero. For historical reasons, <code>NULL</code> is accepted and treated as if it were <code>integer(0)</code>. </p> <p>Loss of accuracy can occur when summing values of different signs: this can even occur for sufficiently long integer inputs if the partial sums would cause integer overflow. Where possible extended-precision accumulators are used, typically well supported with C99 and newer, but possibly platform-dependent. </p> <h3>Value</h3> <p>The sum. If all of the <i>M</i> <code>...</code> arguments are of type integer or logical, then the sum is <code><a href="integer.html">integer</a></code> when possible and is <code>double</code> otherwise. Integer overflow should no longer happen since <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> version 3.5.0. For other argument types it is a length-one numeric (<code><a href="double.html">double</a></code>) or complex vector. </p> <p><strong>NB:</strong> the sum of an empty set is zero, by definition. </p> <h3>S4 methods</h3> <p>This is part of the S4 <code><a href="../../methods/html/S4groupGeneric.html">Summary</a></code> group generic. Methods for it must use the signature <code>x, ..., na.rm</code>. </p> <p>‘<a href="../../grDevices/html/plotmath.html">plotmath</a>’ for the use of <code>sum</code> in plot annotation. </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="colSums.html">colSums</a></code> for row and column sums. </p> <h3>Examples</h3> <pre> ## Pass a vector to sum, and it will add the elements together. sum(1:5) ## Pass several numbers to sum, and it also adds the elements. sum(1, 2, 3, 4, 5) ## In fact, you can pass vectors into several arguments, and everything gets added. sum(1:2, 3:5) ## If there are missing values, the sum is unknown, i.e., also missing, .... sum(1:5, NA) ## ... unless we exclude missing values explicitly: sum(1:5, NA, na.rm = TRUE) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>