Skip to contents

Functions

These are miscellaneous functions I’ve written to serve my research or pedagogical needs.

center_at() diff_at() group_mean_center_at() lag_at() log_at() mean_at() r1sd_at() r2sd_at()
Scoped Helper Verbs
binred_plot()
Generate a Binned-Residual Plot from a Fitted Generalized Linear Model
carrec() carr()
Recode a Variable
cor2data()
Simulate Data from Correlation Matrix
corvectors()
Create multivariate data by permutation
db_lselect()
Lazily select variables from multiple tables in a relational database
fct_reorg()
Reorganize a factor after "re-leveling" it
filter_refs()
Filter a Data Frame of Citations and Return the Entries as a Character
get_sims()
Get Simulations from a Model Object (with New Data)
get_var_info() gvi()
Get a small data frame of the variable label and values.
theme_steve_web() post_bg() theme_steve_ms() theme_steve_font()
Legacy functions for Steve's Preferred ggplot2 Themes and Assorted Stuff
jenny()
Set the Only Reproducible Seed That Matters
linloess_plot()
Compare Linear Smoother to LOESS Smoother for Your OLS Model
make_perclab()
Make Percentage Label for Proportion and Add Percentage Sign
make_scale()
Rescale Vector to Arbitrary Minimum and Maximum
mround()
Multiply a Number by 100 and Round It (By Default: 2)
`%nin%`
Find Non-Matching Elements
normal_dist()
Make and annotate a normal distribution with ggplot2
p_z()
Convert the p-value you want to the z-value it actually is
prepare_refs()
Prepare bib2df Data Frame for Formatting to Various Outputs
print_refs()
Print and Format .bib Entries as References
ps_btscs()
Create "peace years" or "spells" by cross-sectional unit, more generally
ps_spells()
Create "spells" by cross-sectional unit, even more generally
r1sd()
Scale a vector by one standard deviation
r2sd()
Scale a vector (or vectors) by two standard deviations
rbnorm()
Bounded Normal (Really: Scaled Beta) Distribution
rd_plot()
Residual Density Plot for Linear Models
revcode()
Reverse code a numeric variable
sbayesboot()
Bootstrap a Regression Model, the Bayesian Way
sbtscs()
Create "peace years" or "spells" by cross-sectional unit
show_ranef()
Get a caterpillar plot of random effects from a mixed model
smvrnorm()
Simulate from a Multivariate Normal Distribution
dst() pst() qst() rst()
The Student-t Distribution (Location-Scale)
tbl_df() to_tbl()
Convert data frame to an object of class "tibble"
wls()
Get Weighted Least Squares of Your OLS Model
wom()
Generate Week of the Month from a Date

Datasets

These are toy data sets necessary for illustrating or testing functions, or might be data sets that just found their way here for one reason or another.

charitable_contributions
Charitable Contributions Panel Data
ess9_labelled
Some Labeled Data in the European Social Survey (Round 9)
fra_leaderyears
French Leader-Years, 1874-2015
gmy_dyadyears
German Dyad-Years, 1816-2020
map_quiz
Map Quiz Wrong Guesses Across Five Intro to IR Courses
stevepubs
An Incomplete List of My Publications, All of Which You Should Cite
strategic_rivalries
Strategic Rivalries, 1494-2010
usa_mids
United States Militarized Interstate Disputes (MIDs)