Continuously updated collection of little helpers (tm) that facilitates my life in analyzing data (mostly comparative datasets) with R.
remotes::install_github("maksimrudnev/LittleHelpers") to install.
- Multilevel helpers
- Multigroup helpers
- Tools for labelled data and Rstudio viewer
- Pipe helpers [removed, see gist]
- Values, Schwartz, ESS
Explore multilevel data:
cor_withinprints and plots individual correlations within each group.
cor_betweencomputes means and shows group-level correlation between two variables.
scatter_means_ciComputes means by group and plots on scatterplot against each other (shows country-level correlations).
graph_means_ciPlots means by group.
stacked_barComputes proportions cross-table and plots them in a nice way, returns ggplot object, so any further
+scale_x(), etc. codes can be added.
Recode multilevel data:
aggr_and_mergehelps to create group-level variables from individual-level variables and merge them back to the data.frame on the go.
grand_centerQuick grand-mean centering.
group_centerQuick group-mean centering.
Summarize and visualize multilevel regressions:
good_tableLarge function that creates customizable coefficients tables using multiple lmer models; outputs in Rstudio viewer.
potential_interactionsExploratory. If you have no idea what cross-level interactions to look for. Computes pairwise tests of all the possible interactions in the
lmer()model, or simply shows correlations between random effects and group-level variables.
random_interactionPlots cross-level interactions for
lmer()-fitted models. Customizable. Can automatically choose real moderator values close to mean+-(2)SD.
random_plotPlots random effects from
plefQuick interaction plot for simple models
Compute extra stats for multilevel regressions:
explained_variance.merModComputes psudo-R-square for two-level regressions fitted with
vif_merCompute variance inflation factor for multilevel regressions fitted with
lavaan::lavTestScore(), merging parameter labels with parameters and groups names and adding stars. Useful when you decide with between-group contraints might be relaxed.
mgcfa_diagnosePrint comprehensible output to diagnose problems with MGCFA models.
mi_testSeries of measurement invariance tests, analoigous to
Tools for labelled data and Rstudio viewer
Know the labels:
label_bookCreates a codebook for data.frames with labels.
Make use of labels:
cor_tablePrints ready-to-publish correlation tables with significance stars.
crosstabSimple cross-tabulation with labels.
Get rid of labels and other tidyverse attributes:
drop_labsDrops labels if you don't need them.
untibbleGet rid of tibble and get clean data.frame.
lab_to_facConverts labelled variables to factors.
Make use of Rstudio viewer:
df_to_viewerPuts any data.frame to RStudio viewer. Also works with models and anything that can be passed through
Values, Schwartz, ESS
valueslist of value labels.
download_essDownload European Social Survey data
schwartz_circleDraw Schwartz circle and more with three simple functions:
ess_valuesComputes 2, 4, or 10 value indices as they are measured in ESS.
reverseRecodes variable in reverse order. Works with labels.
replace_by_tableUseful for recoding when matching tables are alsready specified in a table. Particularly useful for translation.
mean_se_lower_upperSimply mean, SE, upper and lower 95% CI.
verbSimply prints its arguments.
renameRenames variables in data.frame without bullshittery.
theme_mrClean theme for ggplot.
convergencePlotsMplusExtract Bayesian data from data Mplus, draw trace plots and autocorrelation plots, and save in a single pdf.