blob: ae9423a3821fe499149796d902df7ba435b567b3 [file] [log] [blame]
<!DOCTYPE html><html><head><title>R: corr</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.css">
<script type="text/javascript">
const macros = { "\\R": "\\textsf{R}", "\\code": "\\texttt"};
function processMathHTML() {
var l = document.getElementsByClassName('reqn');
for (let e of l) { katex.render(e.textContent, e, { throwOnError: false, macros }); }
return;
}</script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.js"
onload="processMathHTML();"></script>
<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><div class="container">
<table style="width: 100%;"><tr><td>corr {SparkR}</td><td style="text-align: right;">R Documentation</td></tr></table>
<h2>corr</h2>
<h3>Description</h3>
<p>Computes the Pearson Correlation Coefficient for two Columns.
</p>
<h3>Usage</h3>
<pre><code class='language-R'>corr(x, ...)
## S4 method for signature 'Column'
corr(x, col2)
## S4 method for signature 'SparkDataFrame'
corr(x, colName1, colName2, method = "pearson")
</code></pre>
<h3>Arguments</h3>
<table>
<tr style="vertical-align: top;"><td><code>x</code></td>
<td>
<p>a Column or a SparkDataFrame.</p>
</td></tr>
<tr style="vertical-align: 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 style="vertical-align: top;"><td><code>col2</code></td>
<td>
<p>a (second) Column.</p>
</td></tr>
<tr style="vertical-align: top;"><td><code>colName1</code></td>
<td>
<p>the name of the first column</p>
</td></tr>
<tr style="vertical-align: top;"><td><code>colName2</code></td>
<td>
<p>the name of the second column</p>
</td></tr>
<tr style="vertical-align: top;"><td><code>method</code></td>
<td>
<p>Optional. A character specifying the method for calculating the correlation.
only &quot;pearson&quot; is allowed now.</p>
</td></tr>
</table>
<h3>Value</h3>
<p>The Pearson Correlation Coefficient as a Double.
</p>
<h3>Note</h3>
<p>corr since 1.6.0
</p>
<p>corr since 1.6.0
</p>
<h3>See Also</h3>
<p>Other aggregate functions:
<code><a href="../../SparkR/help/avg.html">avg</a>()</code>,
<code><a href="../../SparkR/help/column_aggregate_functions.html">column_aggregate_functions</a></code>,
<code><a href="../../SparkR/help/count.html">count</a>()</code>,
<code><a href="../../SparkR/help/cov.html">cov</a>()</code>,
<code><a href="../../SparkR/help/first.html">first</a>()</code>,
<code><a href="../../SparkR/help/last.html">last</a>()</code>
</p>
<p>Other stat functions:
<code><a href="../../SparkR/help/approxQuantile.html">approxQuantile</a>()</code>,
<code><a href="../../SparkR/help/cov.html">cov</a>()</code>,
<code><a href="../../SparkR/help/crosstab.html">crosstab</a>()</code>,
<code><a href="../../SparkR/help/freqItems.html">freqItems</a>()</code>,
<code><a href="../../SparkR/help/sampleBy.html">sampleBy</a>()</code>
</p>
<h3>Examples</h3>
<pre><code class="r">## Not run:
##D df &lt;- createDataFrame(cbind(model = rownames(mtcars), mtcars))
##D head(select(df, corr(df$mpg, df$hp)))
## End(Not run)
## Not run:
##D corr(df, &quot;mpg&quot;, &quot;hp&quot;)
##D corr(df, &quot;mpg&quot;, &quot;hp&quot;, method = &quot;pearson&quot;)
## End(Not run)
</code></pre>
<hr /><div style="text-align: center;">[Package <em>SparkR</em> version 3.2.2 <a href="00Index.html">Index</a>]</div>
</div>
</body></html>