I would like to plot the results of a GAM as dot-and-whisker plots using the dwplot() command in the dotwhisker R package. The example in the package documentation is as follows:
#Package preload
library(dotwhisker)
library(broom)
library(dplyr)
# run a regression compatible with tidy
m1 <- lm(mpg ~ wt + cyl + disp + gear, data = mtcars)
m1_df <- tidy(m1) # create data.frame of regression results
m1_df # a tidy data.frame available for dwplot
dwplot(m1_df) #same as dwplot(m1)
I have two questions:
Thanks,
Josh
You can try something like this:
dwplot(m1_df) + ylim(breaks=c("wt","cyl")) + coord_flip()
In the ylim()
function, you can specify the breaks (factors) to include when the axis is discrete. And coord_flip()
simply flips the plot around.