View source: R/effective_functions.r
letter_plot | R Documentation |
Produces an dot plot with error bars along with a compact letter display
letter_plot(fits, letters)
fits |
Output from |
letters |
A matrix of character strings giving the letters from a
compact letter display. This is most often from a call to |
A ggplot.
library(psre)
library(ggeffects)
library(multcomp)
library(dplyr)
library(ggplot2)
data(wvs)
wvs$civ <- with(wvs, case_when(
civ == 4 ~ "Islamic",
civ == 6 ~ "Latin American",
civ == 7 ~ "Orthodox",
civ == 8 ~ "Sinic",
civ == 9 ~ "Western",
TRUE ~ "Other"))
wvs$civ = factor(wvs$civ, levels=c("Western",
"Sinic",
"Islamic",
"Latin American",
"Orthodox",
"Other"))
mod <- lm(resemaval ~ civ + gdp_cap +
pct_secondary + pct_univ_degree +
pct_high_rel_imp, data=wvs)
eff <- ggpredict(mod,
"civ",
ci.lvl = .95)
pwc <- summary(glht(mod, linfct=mcp(civ = "Tukey")),
test=adjusted(type="none"))
cld1 <- cld(pwc)
lmat <- cld1$mcletters$LetterMatrix
eff$x <- reorder(eff$x, eff$predicted, mean)
letter_plot(eff, lmat) +
labs(x="Predicted Emancipative Values\n(95% Confidence Interval)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.