The file preload.R
contains some useful R snippets that I have developed over time. This set of snippets makes serious use of R almost possible. This set of snippets is bound to be enhanced and amended over time. Feel free to just copy that file into your own R project. You can load it like this:
source("preload.R")
These snippets default to HC3 standard errors if computing “clustered” standard errors, and to HC5 standard errors if not. (Note: Stata defaults to HC1 standard errors, which are not recommended.)
To use all the functions in preload.R
, you need these R packages:
- texreg, preferably as found here¹
- lmtest
- sandwich
¹ You can use install.packages("remotes"); remotes::install_github("mrpg/texreg_fork")
to install that.
When using tt()
, include these LaTeX packages:
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{microtype}
\usepackage{siunitx}
\usepackage{threeparttable}
See example.R
.
This file also shows a feature of these snippets that is frequently missed: save_to
saves your LaTeX regression table to a file. This means that within your paper, you can do
\input{output/table1.tex}
No more copy and pasting! Crucially, the file name is determined automatically from your list of models.
Unless otherwise noted, everything in this repository is licensed under CC0 1.0 Universal, or (at your option) any later version. See LICENSE
for details. Note that there is absolutely no warranty.