| <!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: cov</title> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| <link rel="stylesheet" type="text/css" href="R.css" /> |
| |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/github.min.css"> |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js"></script> |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/languages/r.min.js"></script> |
| <script>hljs.initHighlightingOnLoad();</script> |
| </head><body> |
| |
| <table width="100%" summary="page for cov {SparkR}"><tr><td>cov {SparkR}</td><td style="text-align: right;">R Documentation</td></tr></table> |
| |
| <h2>cov</h2> |
| |
| <h3>Description</h3> |
| |
| <p>Compute the covariance between two expressions. |
| </p> |
| |
| |
| <h3>Usage</h3> |
| |
| <pre> |
| cov(x, ...) |
| |
| covar_samp(col1, col2) |
| |
| covar_pop(col1, col2) |
| |
| ## S4 method for signature 'characterOrColumn' |
| cov(x, col2) |
| |
| ## S4 method for signature 'characterOrColumn,characterOrColumn' |
| covar_samp(col1, col2) |
| |
| ## S4 method for signature 'characterOrColumn,characterOrColumn' |
| covar_pop(col1, col2) |
| |
| ## S4 method for signature 'SparkDataFrame' |
| cov(x, colName1, colName2) |
| </pre> |
| |
| |
| <h3>Arguments</h3> |
| |
| <table summary="R argblock"> |
| <tr valign="top"><td><code>x</code></td> |
| <td> |
| <p>a Column or a SparkDataFrame.</p> |
| </td></tr> |
| <tr valign="top"><td><code>...</code></td> |
| <td> |
| <p>additional argument(s). If <code>x</code> is a Column, a Column |
| should be provided. If <code>x</code> is a SparkDataFrame, two column names should |
| be provided.</p> |
| </td></tr> |
| <tr valign="top"><td><code>col1</code></td> |
| <td> |
| <p>the first Column.</p> |
| </td></tr> |
| <tr valign="top"><td><code>col2</code></td> |
| <td> |
| <p>the second Column.</p> |
| </td></tr> |
| <tr valign="top"><td><code>colName1</code></td> |
| <td> |
| <p>the name of the first column</p> |
| </td></tr> |
| <tr valign="top"><td><code>colName2</code></td> |
| <td> |
| <p>the name of the second column</p> |
| </td></tr> |
| </table> |
| |
| |
| <h3>Details</h3> |
| |
| <p><code>cov</code>: Compute the sample covariance between two expressions. |
| </p> |
| <p><code>covar_sample</code>: Alias for <code>cov</code>. |
| </p> |
| <p><code>covar_pop</code>: Computes the population covariance between two expressions. |
| </p> |
| <p><code>cov</code>: When applied to SparkDataFrame, this calculates the sample covariance of two |
| numerical columns of <em>one</em> SparkDataFrame. |
| </p> |
| |
| |
| <h3>Value</h3> |
| |
| <p>The covariance of the two columns. |
| </p> |
| |
| |
| <h3>Note</h3> |
| |
| <p>cov since 1.6.0 |
| </p> |
| <p>covar_samp since 2.0.0 |
| </p> |
| <p>covar_pop since 2.0.0 |
| </p> |
| <p>cov since 1.6.0 |
| </p> |
| |
| |
| <h3>See Also</h3> |
| |
| <p>Other aggregate functions: <code><a href="avg.html">avg</a></code>, |
| <code><a href="column_aggregate_functions.html">column_aggregate_functions</a></code>, |
| <code><a href="corr.html">corr</a></code>, <code><a href="count.html">count</a></code>, |
| <code><a href="first.html">first</a></code>, <code><a href="last.html">last</a></code> |
| </p> |
| <p>Other stat functions: <code><a href="approxQuantile.html">approxQuantile</a></code>, |
| <code><a href="corr.html">corr</a></code>, <code><a href="crosstab.html">crosstab</a></code>, |
| <code><a href="freqItems.html">freqItems</a></code>, <code><a href="sampleBy.html">sampleBy</a></code> |
| </p> |
| |
| |
| <h3>Examples</h3> |
| |
| <pre><code class="r">## Not run: |
| ##D df <- createDataFrame(cbind(model = rownames(mtcars), mtcars)) |
| ##D head(select(df, cov(df$mpg, df$hp), cov("mpg", "hp"), |
| ##D covar_samp(df$mpg, df$hp), covar_samp("mpg", "hp"), |
| ##D covar_pop(df$mpg, df$hp), covar_pop("mpg", "hp"))) |
| ## End(Not run) |
| |
| ## Not run: |
| ##D cov(df, "mpg", "hp") |
| ##D cov(df, df$mpg, df$hp) |
| ## End(Not run) |
| </code></pre> |
| |
| |
| <hr /><div style="text-align: center;">[Package <em>SparkR</em> version 2.3.2 <a href="00Index.html">Index</a>]</div> |
| </body></html> |