Learn R Programming

bruceR

BRoadly Useful Convenient and Efficient R functions that BRing Users Concise and Elegant R data analyses.

This package includes easy-to-use functions for:

  1. Basic R programming (e.g., set working directory to the path of currently opened file; import/export data from/to files in any format; print tables to Microsoft Word);
  2. Multivariate computation (e.g., compute scale sums/means/... with reverse scoring);
  3. Reliability analyses and factor analyses (PCA, EFA, CFA);
  4. Descriptive statistics and correlation analyses;
  5. t-test, multi-factor analysis of variance (ANOVA), simple-effect analysis, and post-hoc multiple comparison;
  6. Tidy report of statistical models (to R Console and Microsoft Word);
  7. Mediation and moderation analyses (PROCESS);
  8. Additional toolbox for statistics and graphics.

Author

Bruce H. W. S. Bao 包寒吴霜

Copy Link

Version

Install

install.packages('bruceR')

Monthly Downloads

3,397

Version

2025.11

License

GPL-3

Maintainer

Han-Wu-Shuang Bao

Last Published

December 9th, 2025

Functions in bruceR (2025.11)

RGB

LOOKUP

Search, match, and look up values (like Excel's functions INDEX + MATCH).
Run

Run code parsed from text.
Print

Print strings with rich formats and colors.
TTEST

One-sample, independent-samples, and paired-samples t-test.
add

Create, modify, and delete variables.
PROCESS

Model-based mediation and moderation analyses (named after but distinct from SPSS PROCESS).
RESCALE

Rescale a variable (e.g., from 5-point to 7-point).
RECODE

Recode a variable.
MANOVA

Multi-factor ANOVA.
bruceR-demodata

Demo data.
dtime

Timer (compute time difference).
cc

Split up a string (with separators) into a character vector.
bruceR-package

bruceR: BRoadly Useful Convenient and Efficient R functions
formatF

Format numeric values.
formatN

Format "1234" to "1,234".
formula_expand

Expand all interaction terms in a formula.
formula_paste

Paste a formula into a string.
granger_causality

Granger causality test (multivariate).
grand_mean_center

Grand-mean centering.
ccf_plot

Cross-correlation analysis.
%anyin%

A simple extension of %in%.
med_summary

Tidy report of mediation analysis.
granger_test

Granger causality test (bivariate).
%^%

Paste strings together.
cor_multilevel

Multilevel correlations (within-level and between-level).
cor_diff

Test the difference between two correlations.
%allin%

A simple extension of %in%.
p

Compute p value.
pkg_depend

Check dependencies of R packages.
group_mean_center

Group-mean centering.
%%COMPUTE%%

Multivariate computation.
export

Export data to a file (TXT, CSV, Excel, SPSS, Stata, ...) or clipboard.
regress

Regression analysis.
rep_char

Repeat a character string for many times and paste them up.
model_summary

Tidy report of regression models.
show_colors

Show colors.
theme_bruce

A nice ggplot2 theme that enables Markdown/HTML rich text.
import

Import data from a file (TXT, CSV, Excel, SPSS, Stata, ...) or clipboard.
lavaan_summary

Tidy report of lavaan model.
%nonein%

A simple extension of %in%.
set.wd

Set working directory to the path of currently opened file.
scaler

Min-max scaling (min-max normalization).
reexports

Objects exported from other packages
print_table

Print a three-line table (to R Console and Microsoft Word).
%partin%

A simple extension of %in%.
GLM_summary

Tidy report of GLM (lm and glm models).
EMMEANS

Simple-effect analysis and post-hoc multiple comparison.
Describe

Descriptive statistics.
CFA

Confirmatory Factor Analysis (CFA).
HLM_summary

Tidy report of HLM (lmer and glmer models).
Alpha

Reliability analysis (Cronbach's \(\alpha\) and McDonald's \(\omega\)).
HLM_ICC_rWG

Tidy report of HLM indices: ICC(1), ICC(2), and rWG/rWG(J).
Corr

Correlation analysis.
EFA

Principal Component Analysis (PCA) and Exploratory Factor analysis (EFA).
Freq

Frequency statistics.