Skip to content

Instantly share code, notes, and snippets.

@derekpowell
Last active April 14, 2018 00:31
Show Gist options
  • Save derekpowell/fd2d67f0b3334caf534abceb65401e0b to your computer and use it in GitHub Desktop.
Save derekpowell/fd2d67f0b3334caf534abceb65401e0b to your computer and use it in GitHub Desktop.
R: extract ggplot object from brm marginal_effects() plot
gg_marginal_effects <- function(model, effects, probs=c(0.25, 0.75)) {
me <- brms::marginal_effects(model, effects=effects, probs=probs)
plt.me <- plot(me,
effects=effects,
plot=FALSE,
rug=TRUE,
theme=ggplot2::theme_get()
)[[1]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment