Consider this data frame:
set.seed(123)
dat1 <- data.frame(Loc = rep(letters[1:20], each = 10),
ID = 1:200,
var1 = rnorm(200))
dat1$ID <- factor(dat1$ID)
I want to return a data frame that shows all possible pairwise comparisons that could be performed on the levels of Loc
, which would look like this:
Loc1 Loc2
a b
a c
a d
a e
…
#and so on, just like a post hoc test would return (e.g. Tukey's)
But how do you do this between the levels of a single column?