EVOLUTION-MANAGER
Edit File: ave.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: Group Averages Over Level Combinations of Factors</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 ave {stats}"><tr><td>ave {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Group Averages Over Level Combinations of Factors</h2> <h3>Description</h3> <p>Subsets of <code>x[]</code> are averaged, where each subset consist of those observations with the same factor levels. </p> <h3>Usage</h3> <pre> ave(x, ..., FUN = mean) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A numeric.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Grouping variables, typically factors, all of the same <code>length</code> as <code>x</code>.</p> </td></tr> <tr valign="top"><td><code>FUN</code></td> <td> <p>Function to apply for each factor level combination.</p> </td></tr> </table> <h3>Value</h3> <p>A numeric vector, say <code>y</code> of length <code>length(x)</code>. If <code>...</code> is <code>g1, g2</code>, e.g., <code>y[i]</code> is equal to <code>FUN(x[j]</code>, for all <code>j</code> with <code>g1[j] == g1[i]</code> and <code>g2[j] == g2[i])</code>. </p> <h3>See Also</h3> <p><code><a href="../../base/html/mean.html">mean</a></code>, <code><a href="median.html">median</a></code>.</p> <h3>Examples</h3> <pre> require(graphics) ave(1:3) # no grouping -> grand mean attach(warpbreaks) ave(breaks, wool) ave(breaks, tension) ave(breaks, tension, FUN = function(x) mean(x, trim = 0.1)) plot(breaks, main = "ave( Warpbreaks ) for wool x tension combinations") lines(ave(breaks, wool, tension ), type = "s", col = "blue") lines(ave(breaks, wool, tension, FUN = median), type = "s", col = "green") legend(40, 70, c("mean", "median"), lty = 1, col = c("blue","green"), bg = "gray90") detach() </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>