I would like to plot the output from more than one regression.
MWE:
df <- data.frame(
y1 = runif(100),
y2 = runif(100),
x = c(rep("A",times=50), rep("B",times=50))
)
If I want to plot the intercept and coefficients, I can use dwplot():
m0 <- lm(y1 ~ factor(x), data = df)
m1 <- lm(y2 ~ factor(x), data = df)
dwplot(list(m0, m1), show_intercept=T) + theme_bw()
However, I am interested in the ls means (computed with the package library(lsmeans)). For this case, dwplot() gives me an error.
lsm0 <- lsmeans(m0,~ factor(x), data = df)
lsm1 <- lsmeans(m1,~ factor(x), data = df)
dwplot(list(lsm0, lsm1), show_intercept=T) + theme_bw()
What are possible solutions?
You could use the results from both object and create one dataframe to make your own ggplot with
geom_pointrangelike this:Created on 2023-04-07 with reprex v2.0.2