Learn R Programming

⚠️There's a newer version (2023.9) of this package.Take me there.

bruceR

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

The package includes easy-to-use functions for (1) basic use and analysis; (2) multivariate computation; (3) reliability and validity analysis; (4) multi-factor analysis of variance (ANOVA), simple-effect analysis, and post-hoc multiple comparison; and (5) advanced toolbox and tidy report of statistical models.

Author

包寒吴霜 | Bao H.-W.-S.

E-mail: baohws@foxmail.com

Website: psychbruce.github.io

ResearchGate | GitHub | 知乎

Citation

User Guide

Release Notes

Installation

## Method 1: Install from CRAN
install.packages("bruceR")

## Method 2: Install from GitHub
install.packages("devtools")
devtools::install_github("psychbruce/bruceR", force=TRUE, upgrade=FALSE)

Tips:

  1. Please restart (close and reopen) RStudio before installation.
  2. If you see a dialog asking "Do you want to install from sources the package which needs compilation?", it would be better to choose "No" (to save your time).
  3. If you fail to install, please read carefully the warning messages and find out the key R package(s) causing the failure, manually uninstall and reinstall these R package(s), and then retry the main installation.
  4. It would be better to update R to its latest version (v4.0+).
  5. It would be better to download and install Rtools.exe on Windows system.

Package Dependency

bruceR depends on many important R packages.

Loading bruceR by library(bruceR) will also load these R packages for you:

  • [Data]:

    • rio: Data import and export (for all file formats).
    • dplyr: Data manipulation and processing.
    • tidyr: Data cleaning and reshaping.
    • stringr: Toolbox for string operation (with regular expressions).
    • forcats: Toolbox for factor manipulation (for categorical variables).
    • data.table: Advanced data.frame with higher efficiency.
  • [Stat]:

    • psych: Toolbox for psychological and psychometric research.
    • emmeans: Toolbox for estimated marginal means and contrasts.
    • effectsize: Indices of effect size and standardized parameters.
    • performance: Assessment of regression models performance.
  • [Plot]:

    • ggplot2: Data visualization.
    • cowplot: Advanced toolbox for ggplot2 (arrange multiple plots and add labels).
    • see: Advanced toolbox for ggplot2 (extra geoms, scales, themes, and color palettes).

Main Functions in bruceR

  1. Basic Use and Analysis

    • set.wd()
    • pkg_depend(), pkg_install_suggested()
    • formatF(), formatN()
    • Print(), Glue()
    • Describe(), Freq(), Corr(), cor_diff()
    • LOOKUP(), RANDBETWEEN()
    • %notin%, %partin%, %allin%, %nonein%, %anyin%
  2. Multivariate Computation

    • RECODE(), RESCALE()
    • SUM(), MEAN(), STD(), MODE(), COUNT(), CONSEC()
  3. Reliability and Validity Analysis

    • Alpha()
    • EFA()
    • CFA()
  4. Multi-Factor ANOVA, Simple-Effect Analysis, and Post-Hoc Multiple Comparison

    • MANOVA()
    • EMMEANS()
  5. Advanced Toolbox and Tidy Report of Statistical Models

    • grand_mean_center(), group_mean_center()
    • regress(), GLM_summary(), HLM_summary()
    • model_summary()
    • med_summary()
    • ccf_plot()
    • granger_test()
  6. Theme for ggplot2

    • theme_bruce()

Learn More From Help Pages

library(bruceR)

## Overview
help("bruceR")
help(bruceR)
?bruceR

## See help pages of functions
## (use `?function` or `help(function)`)
?Describe
?Corr
?SUM
?MEAN
?MANOVA
?EMMEANS
?model_summary
?med_summary
?GLM_summary
?HLM_summary
...

Copy Link

Version

Install

install.packages('bruceR')

Monthly Downloads

2,614

Version

0.6.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Han-Wu-Shuang Bao

Last Published

March 19th, 2021

Functions in bruceR (0.6.0)

Corr

Correlation analysis.
GLM_summary

Advanced report of GLM (lm and glm models).
Describe

Descriptive statistics.
CFA

Confirmatory factor analysis (CFA).
HLM_summary

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

Reliability analysis (Cronbach's \(\alpha\) and corrected item-total correlation).
LOOKUP

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

Frequency statistics.
EFA

Exploratory factor analysis (EFA).
EMMEANS

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

Rescale likert scales (e.g., from 5-point to 7-point).
RECODE

Recode a variable.
formula_expand

Expand all interaction terms in a formula.
RANDBETWEEN

Random sampling (like Excel's function RANDBETWEEN).
formatN

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

Format numeric values.
dtime

Timer (compute time difference).
bruceR-demodata

Demo data.
bruceR-package

bruceR: BRoadly Useful Convenient and Efficient R functions
ccf_plot

Cross-correlation analysis.
cor_diff

Test the difference between two correlations.
granger_test

Granger causality test.
med_summary

Tidy report of mediation analysis.
RGB

A simple extension of rgb().
p.trans2

Transform p value.
Print

Print texts with rich formats and colors.
model_summary

Tidy report of regression models (into R console, Word, or HTML).
formula_paste

Paste a formula into a string.
MANOVA

Multi-factor ANOVA.
p

Compute p value.
%allin%

A simple extension of %in%.
p.trans

Transform p value.
print_table

Print a three-line table.
pkg_install_suggested

Install suggested R packages.
grand_mean_center

Grand-mean centering.
pkg_depend

Check dependencies of R packages.
%%COMPUTE%%

Multivariate computation.
group_mean_center

Group-mean centering
%anyin%

A simple extension of %in%.
%partin%

A simple extension of %in%.
sig.trans

Transform p value to significance code.
theme_bruce

A nice ggplot2 theme for scientific publication.
set.wd

Set working directory to where the current file is.
scaler

Min-max scaling (min-max normalization).
%nonein%

A simple extension of %in%.
regress

Regression analysis.
%notin%

A simple extension of %in%.
rep_char

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