knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
vmisc is a small R package for convenience functions and plotting themes. You are probably here because you wanted to try one of the ggplot2 themes, in which case see below:
You can install vmisc from github with:
# install.packages("devtools") devtools::install_github("mvuorre/vmisc")
See below for examples of the themes in the vmisc package.
library(ggplot2) library(gridExtra) library(vmisc) p <- ggplot(mtcars, aes(x=hp, y=mpg, col=as.factor(vs))) + geom_point() + geom_line() + facet_wrap("am", labeller = label_both, nrow=1)
theme_vmisc()
is the base plot on which the other themes are built. It has three key options, illustrated below:
grid.arrange( p + theme_vmisc(), p + theme_vmisc(legend = "top"), p + theme_vmisc(grid = TRUE), p + theme_vmisc(facet_label = TRUE) )
theme_vmisc()
, with its three main options, replaces old functions theme_blog()
, theme_poster()
, and theme_pub()
. Using these themes now gives a warning that they are deprecated:
p + theme_blog() + ggtitle("theme_blog()")
p + theme_poster(base_family = "Comic Sans MS") + ggtitle("theme_poster()")
p + theme_pub(base_size = 14) + ggtitle("theme_pub()")
theme_beamer()
is tailored for Beamer pdf presentations, but accepts same three arguments as theme_vmisc()
:
p + theme_beamer() + ggtitle("theme_beamer()")
brms_forest()
is a convenience function for drawing forest plots from meta-analysis models fitted with brms. See ?brms_forest
. The function is experimental and may contain bugs; if you find one, please leave an issue on GitHub.
Example use:
library(metafor) library(dplyr) d <- dat.bangertdrowns2004 %>% mutate(author = paste0(author, " (", year, ")"), sei = sqrt(vi)) %>% select(id, author, yi, sei) %>% slice(1:10)
To estimate a brms meta-analytic model on above data, run:
library(brms) fit <- brm(yi | se(sei) ~ 1 + (1|id), data = d, cores = 4, control=list(adapt_delta = .99)) save(fit, file="tmp.rda")
load(here::here("tmp.rda"))
To draw the forest plot:
x <- brms_forest(data = d, model = fit, study = "id", label = "author", xlim = c(-2,2), level = .99, show_data = TRUE, sort_estimates = F) x + ylab("Effect Size") + scale_y_continuous(breaks = c(-1, 2))
New brmsfit method:
fit <- brm(yi | se(sei) ~ 1 + (1|author), data = d, cores = 4, control=list(adapt_delta = .99)) save(fit, file="tmp.rda")
library(vmisc) forest(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.