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?
CodePudding user response:
I am not getting any error messages.
CodePudding user response:
Thank you @Quinten for your suggestion. Indeed unloading the unneccessary packages helped. The package "rstatix" seemed to interfere with the cor_pmat() command.