EVOLUTION-MANAGER
Edit File: weighted.mean.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: Weighted Arithmetic Mean</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 weighted.mean {stats}"><tr><td>weighted.mean {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Weighted Arithmetic Mean</h2> <h3>Description</h3> <p>Compute a weighted mean. </p> <h3>Usage</h3> <pre> weighted.mean(x, w, ...) ## Default S3 method: weighted.mean(x, w, ..., na.rm = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>an object containing the values whose weighted mean is to be computed.</p> </td></tr> <tr valign="top"><td><code>w</code></td> <td> <p>a numerical vector of weights the same length as <code>x</code> giving the weights to use for elements of <code>x</code>.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>arguments to be passed to or from methods.</p> </td></tr> <tr valign="top"><td><code>na.rm</code></td> <td> <p>a logical value indicating whether <code>NA</code> values in <code>x</code> should be stripped before the computation proceeds.</p> </td></tr> </table> <h3>Details</h3> <p>This is a generic function and methods can be defined for the first argument <code>x</code>: apart from the default methods there are methods for the date-time classes <code>"POSIXct"</code>, <code>"POSIXlt"</code>, <code>"difftime"</code> and <code>"Date"</code>. The default method will work for any numeric-like object for which <code>[</code>, multiplication, division and <code><a href="../../base/html/sum.html">sum</a></code> have suitable methods, including complex vectors. </p> <p>If <code>w</code> is missing then all elements of <code>x</code> are given the same weight, otherwise the weights coerced to numeric by <code><a href="../../base/html/numeric.html">as.numeric</a></code> and normalized to sum to one (if possible: if their sum is zero or infinite the value is likely to be <code>NaN</code>). </p> <p>Missing values in <code>w</code> are not handled specially and so give a missing value as the result. However, zero weights <em>are</em> handled specially and the corresponding <code>x</code> values are omitted from the sum. </p> <h3>Value</h3> <p>For the default method, a length-one numeric vector. </p> <h3>See Also</h3> <p><code><a href="../../base/html/mean.html">mean</a></code> </p> <h3>Examples</h3> <pre> ## GPA from Siegel 1994 wt <- c(5, 5, 4, 1)/15 x <- c(3.7,3.3,3.5,2.8) xm <- weighted.mean(x, wt) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>