library(factorplot)
library(ggplot2)
data(chickwts)
mod <- lm(weight ~ feed, data=chickwts)
fp <- factorplot(mod, factor.variable = "feed", order="size")
chick_df <- fp_to_df(fp, type="upper_tri")
ggplot(chick_df, aes(x=row, y=column)) +
geom_tile(aes(fill=difference), color="black") +
geom_text(aes(label = ifelse(p_value < .05, "*", "")), color="white", size=10) +
scale_fill_viridis_c(option = "D", na.value = "transparent") +
theme_classic() +
geom_text(data=chick_df,
aes(x=row, y=column, label=round(estimate, 2))) +
labs(fill="Difference", x="", y="")
Run the code above in your browser using DataLab