Created
December 1, 2019 20:29
-
-
Save bgall/23817e228803798eafc9346dff0c1714 to your computer and use it in GitHub Desktop.
Load packages for simulation-based power calculation
This file contains hidden or 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
######################################################################### | |
# 'loadpkg' function | |
# Checks if a vector of packages are installed. If not, installs the | |
# package. Then loads all packages in vector. | |
######################################################################### | |
loadpkg <- function(toLoad){ | |
for(lib in toLoad){ | |
if(! lib %in% installed.packages()[,1]) { | |
install.packages(lib, repos='http://cran.rstudio.com/') | |
} | |
suppressMessages( library(lib, character.only=TRUE) ) | |
} | |
} | |
# Load dependencies | |
pkgs <- c("dplyr", # for data processing and pipe operators | |
"estimatr", # for fast lm() with clustered SEs | |
"ggplot2", # for visualizing power | |
) | |
loadpkg(pkgs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment