Add p-Values to Correlation Matrix Plot in R (2 Examples) | psych, corrplot & ggcorrplot Packages

preview_player
Показать описание
R code of this video:

x1 <- rnorm(1000)
x2 <- rnorm(1000) + 0.3 * x1
x3 <- runif(1000) - 0.2 * x1 + 0.1 * x2
x4 <- rnorm(1000) + 0.03 * x1
head(data) # Print head of example data

cor_mat <- cor(data) # Correlation matrix of example data
cor_mat # Print correlation matrix

library("psych") # Load psych package

cor_test_mat # Print matrix of p-values

library("corrplot") # Load corrplot package

corrplot(cor_mat) # Draw corrplot

corrplot(cor_mat, # Draw corrplot with p-values
insig = "p-value")

library("ggcorrplot") # Load ggcorrplot package

ggcorrplot(cor_mat) # Draw ggcorrplot

ggcorrplot(cor_mat, # Draw ggcorrplot with p-values

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

You're all business. I love it. These are awesome videos. Thank you!!!

conceptscognitionlabjamier
Автор

Thank you for keep uploading high-quality videos! Really appreciate them! Danke schön! Joachim!

feiluo
Автор

Thank you, once again. Your videos are great. It just happens I am working in the same subject of the video.

johneagle
Автор

How can we calculate p-value for a matrix manually without using base R function?

saeedfarajzadehvalilou
Автор

Well-done brother, Keep it up brother

muhammadameeq
Автор

Why are the p-values not symmetric within the correlation plot? For example the correlation between x4 and x2: is it 0.48 or 0.96?

katharinapuhringer