I'm performing correlation analysis using the corrr package in R, but I'm unable to extract the p values. Does anyone know how to get the p values in corrr package in R?
2 Answers
I would suggest looking at some of the documentation.
As far as I can tell, the intention of the package is to visualize and organize correlation coefficient estimates. It does not seem that the author of the package has any interest in p-value estimation.
If you are interested in computing p-values, I would suggest using a different tool, such as the builtin cor.test()
function.
Here is a suggested workaround:
- Generate a p-value table using one of these tools:
RcmdrMisc::rcorr.adjust()
psych::corr.test()
Then use corrr:as_cordf()
to generate the tidy dataframe with the same structure as a regular corrr correlation table.
Personally, I have used the Hmisc::rcorr()
package, and it works well:
Hmisc::rcorr() %>% `[[`('P') %>% corrr::as_cordf()
-
-
$\begingroup$ I have since used this solution in my own work and I confirm that it works well. $\endgroup$ Aug 18, 2021 at 14:27