<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/formatted-correlation-with-effect-size/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://neuropsychology.github.io/psycho.R//2018/06/28/analyze_correlation.html"> Dominique Makowski</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<ul>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R//2018/06/28/analyze_correlation.html#do-a-correlation" target="_blank">Do a correlation</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R//2018/06/28/analyze_correlation.html#apa-formatted-output" target="_blank">APA formatted output</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R//2018/06/28/analyze_correlation.html#dataframe-of-values" target="_blank">Dataframe of Values</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R//2018/06/28/analyze_correlation.html#bayesian-correlation" target="_blank">Bayesian Correlation</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R//2018/06/28/analyze_correlation.html#contribute" target="_blank">Contribute</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R//2018/06/28/analyze_correlation.html#credits" target="_blank">Credits</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R//2018/06/28/analyze_correlation.html#previous-blogposts" target="_blank">Previous blogposts</a></li>
</ul>
<p>One of the most time-consuming part of data analysis in psychology is the copy-pasting of specific values of some R output to a manuscript or a report. This task is frustrating, prone to errors, and increase de variability of statistical reporting. At the sime time, standardizing practices of what and how to report is crucial for reproducibility and clarity. <strong>The <a rel="nofollow" href="https://github.com/neuropsychology/psycho.R" target="_blank">psycho</a> package was designed specifically to do this job</strong>, at first for complex <a rel="nofollow" href="https://cran.r-project.org/web/packages/psycho/vignettes/bayesian.html" target="_blank">Bayesian mixed models</a>, but is now also compatible with basic methods, such as <strong>correlation</strong>.</p>
<h1>Do a correlation</h1>
<div>
<div>
<pre><code><span>df</span><span> </span><span>&lt;-</span><span> </span><span>iris</span><span> </span><span># Load the traditional iris dataset into an object called df (for dataframe)</span><span>
</span><span>cor_results</span><span> </span><span>&lt;-</span><span> </span><span>cor.test</span><span>(</span><span>df</span><span>$</span><span>Sepal.Length</span><span>,</span><span> </span><span>df</span><span>$</span><span>Petal.Length</span><span>)</span><span> </span><span># Compute a correlation and store its result</span><span>
</span></code></pre>
</div>
</div>
<h1>APA formatted output</h1>
<div>
<div>
<pre><code><span># devtools::install_github(&quot;neuropsychology/psycho.R&quot;) # Install the latest psycho version</span><span>
</span><span>library</span><span>(</span><span>psycho</span><span>)</span><span> </span><span># Load the psycho package</span><span>
</span><span>psycho</span><span>::</span><span>analyze</span><span>(</span><span>cor_results</span><span>)</span><span> </span><span># Run the analyze function on the correlation</span><span>
</span></code></pre>
</div>
</div>
<div>
<div>
<pre><code>The Pearson's product-moment correlation between df$Sepal.Length and df$Petal.Length is significantly large and positive (r(148) = 0.87, 95% CI [0.83, 0.91], p &lt; .001).
</code></pre>
</div>
</div>
<p>The formatted output includes the <strong>direction</strong>, <strong>effect size</strong> (interpreted by default with <strong><a rel="nofollow" href="https://github.com/neuropsychology/psycho.R/blob/master/R/interpret_r.R#L142" target="_blank">Cohen’s (1988)</a></strong> rules of thumb) and <strong>confidence intervals</strong>. Now, you can just copy and paste this line into your report and focus on more important things than formatting.</p>
<h1>Dataframe of Values</h1>
<p>It is also possible to have all the values stored in a dataframe by running a <strong>summary</strong> on the analyzed object.</p>
<div>
<div>
<pre><code><span>results</span><span> </span><span>&lt;-</span><span> </span><span>analyze</span><span>(</span><span>cor_results</span><span>)</span><span>
</span><span>summary</span><span>(</span><span>results</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<table>
<thead>
<tr>
<th>effect</th>
<th>statistic</th>
<th>df</th>
<th>p</th>
<th>CI_lower</th>
<th>CI_higher</th>
</tr>
</thead>
<tbody>
<tr>
<td>0.872</td>
<td>21.646</td>
<td>148</td>
<td>0</td>
<td>0.827</td>
<td>0.906</td>
</tr>
</tbody>
</table>
<h1>Bayesian Correlation</h1>
<p>Nevertheless, we recommand doing a <strong>Bayesian correlation</strong>, which is even <a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/06/11/bayesian_correlation.html" target="_blank">easier and quicker to do</a>!</p>
<h1>Contribute</h1>
<p>Of course, these reporting standards are bound to change, depending on new expert recommandations or official guidelines. <strong>The goal of this package is to flexibly accompany new changes and good practices evolution</strong>. Therefore, if you have any advices, opinions or such, we encourage you to either let us know by opening an <a rel="nofollow" href="https://github.com/neuropsychology/psycho.R/issues" target="_blank">issue</a> or, <em>even better</em>, try to implement them yourself by <a rel="nofollow" href="https://github.com/neuropsychology/psycho.R/blob/master/.github/CONTRIBUTING.md" target="_blank">contributing</a> to the code.</p>
<h1>Credits</h1>
<p>This package helped you? Don’t forget to cite the various packages you used <img alt="🙂" src="https://s.w.org/images/core/emoji/2.4/72x72/1f642.png" class="wp-smiley"></p>
<p>You can cite <code>psycho</code> as follows:</p>
<ul>
<li>Makowski, (2018). <em>The psycho Package: An Efficient and Publishing-Oriented Workflow for Psychological Science</em>. Journal of Open Source Software, 3(22), 470. <a rel="nofollow" href="https://doi.org/10.21105/joss.00470" target="_blank">https://doi.org/10.21105/joss.00470</a></li>
</ul>
<h1>Previous blogposts</h1>
<ul>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/06/25/refdata.html" target="_blank">Extracting a Reference Grid of your Data for Machine Learning Models Visualization</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/06/19/analyze_ttest.html" target="_blank">Copy/paste t-tests Directly to Manuscripts</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/06/11/bayesian_correlation.html" target="_blank">Easy APA Formatted Bayesian Correlation</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/06/03/plot_bayesian_model.html" target="_blank">Fancy Plot (with Posterior Samples) for Bayesian Regressions</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/05/24/n_factors.html" target="_blank">How Many Factors to Retain in Factor Analysis</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/05/20/correlation.html" target="_blank">Beautiful and Powerful Correlation Tables</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/05/10/interpret_mixed_models.html" target="_blank">Format and Interpret Linear Mixed Models</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/05/01/repeated_measure_anovas.html" target="_blank">How to do Repeated Measures ANOVAs</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/03/29/standardize.html" target="_blank">Standardize (Z-score) a dataframe</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/03/29/SDT.html" target="_blank">Compute Signal Detection Theory Indices</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/03/21/installingR.html" target="_blank">Installing R, R Studio and psycho</a></li>
</ul>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://neuropsychology.github.io/psycho.R//2018/06/28/analyze_correlation.html"> Dominique Makowski</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/U1QNlBC5kzg" height="1"></a></div>