简体   繁体   中英

Error message when using ggcorrplot() and cor_pmat()

I have trouble with the following code:

library(ggplot2)
library(ggcorrplot)
data(USArrests)
correlation_matrix <- round(cor(USArrests),1)
corrp.mat <- cor_pmat(USArrests)
ggcorrplot(correlation_matrix, hc.order =TRUE, type ="lower", 
           p.mat = corrp.mat)

When I run the code, execution stops at ggcorrplot(...) and I get this error:

"Error in Math.data.frame(x = list(Assault = c(0.0695, 1.36e-07, 2.6e-12, : non-numeric-alike variable(s) in data frame: rowname"

I tried to run the code in an online R runner and it worked, but in RStudio it doesn´t.

I have no clue whats going on, has somebody an idea?

I am not getting any error messages.

在此处输入图像描述

Thank you @Quinten for your suggestion. Indeed unloading the unneccessary packages helped. The package "rstatix" seemed to interfere with the cor_pmat() command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM