3
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ If one of the solutions works for you, you can mark it as an accepted answer. $\endgroup$
    – Ochado
    Aug 18 at 14:26
5
$\begingroup$

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.

$\endgroup$
0
1
$\begingroup$

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()
$\endgroup$
2
  • $\begingroup$ got it. thank you so much $\endgroup$
    – rahul
    Aug 15 at 20:46
  • $\begingroup$ I have since used this solution in my own work and I confirm that it works well. $\endgroup$
    – Ochado
    Aug 18 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.