This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## DATA GENERATION | |
# reproducibility | |
library(bayesplot) | |
set.seed(1839) | |
# matches the stan function | |
inv_logit <- function(x){ | |
exp(x) / (1 + exp(x)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Installs any packages not already installed | |
#' @examples | |
#' \dontrun{ | |
#' install_if_missing(c('tidyverse','github.com/stan-dev/cmdstanr')) | |
#' } | |
install_if_missing = function(pkgs){ | |
missing_pkgs = NULL | |
for(this_pkg in pkgs){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' @title Extract ggplot2 plots from a list | |
#' @description Takes a list (potentially containing sublists) and extracts all of the ggplot2 'plot-type' objects from that list into a simple list of 'plot-type' objects. | |
#' @param x A list object, potentially containing sublists. | |
#' @return Returns a 'flat', single-level list of all the ggplot2 'plot-type' objects from within `x`, reaching recursively into sub-lists as needed. If there are no 'plot-type' objects, returns an empty list. | |
#' @note Whether an object is a ggplot2 'plot-type' object is defined here as an object with classes 'gg', 'gTree', or 'gtable'. | |
#' @export | |
#' @examples | |
#' | |
#' library(ggplot2) | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(xtable) | |
#' Prints a LaTeX table with numeric columns aligned on their decimal points. | |
#' | |
#' This function wraps the \code{\link{xtable}} and \code{\link{print.xtable}} | |
#' functions in the \code{xtable} package so that numeric columns are aligned | |
#' on their decimal place. | |
#' | |
#' See \url{http://jason.bryer.org/posts/2013-01-04/xtable_with_aligned_decimals.html} | |
#' for more information. |