Skip to content

Instantly share code, notes, and snippets.

@rubenarslan
rubenarslan / ggprplots.R
Last active December 17, 2015 10:58 — forked from masverba/ggprplots.R
new ggplot 2 syntax, return data object, print plot, fix wrong name for first argument
ggprplots <- function(fit, alpha=0.1) {
design <- model.matrix(fit)
# Skip the intercept term, if any.
m0 <- if (colnames(design)[1] == '(Intercept)') { 2 } else { 1 }
M <- ncol(design)
data <- do.call(rbind, lapply(m0:M, function(m) {
var <- colnames(design)[m]