Using the following data frame, I need to do a dunn_test to see which Locs are different from one another according to each var:
set.seed(123)
dat1 <- data.frame(Loc = rep(letters[1:20], each = 10),
ID = 1:200,
var1 = rnorm(200),
var2 = rnorm(200),
var3 = rnorm(200),
var4 = rnorm(200),
var5 = rnorm(200),
var6 = rnorm(200))
dat1$ID <- factor(dat1$ID)
library(rstatix)
res <- dunn_test(dat1, var1 ~ Loc)
How can I make a "correlation matrix of p values" between the Locs from the object res, so that it will look like the following, and show the p values for each pairwise comparison:
a b c d e f g h i j k l m n o p q r s t
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
Here is a base R approach:
You did not indicate what you wanted in the diagonal. Since these are p values, it would make sense to fill the diagonal with 1's: