Learn R Programming

bruceR (version 0.6.0)

bruceR-package: bruceR: BRoadly Useful Convenient and Efficient R functions

Description

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

Check updates on https://github.com/psychbruce/bruceR

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

[Data]:

  • rio: Data import and export (for all file formats). (import / export)

  • 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).

Arguments

Main Functions in <code>bruceR</code>

(1) Basic Use and Analysis

Print (print texts to console with rich formats and colors)

Describe (descriptive statistics)

Freq (frequency statistics with histogram plot)

Corr (correlation analysis with correlation-matrix plot)

p (compute p-values from statistics: z, t, F, r, chi2)

set.wd (a simple extension of setwd)

pkg_depend (check package dependencies)

pkg_install_suggested (install suggested packages)

dtime (compute time difference)

%notin% (the reverse of %in%, return a logical vector specifying values not in a table)

%allin% (return whether all Xs are in a vector)

%anyin% (return whether any of Xs is in a vector)

%nonein% (return whether none of Xs is in a vector)

%partin% (use regular expression to judge whether a pattern exists in a vector)

RANDBETWEEN (random sampling, like Excel's function RANDBETWEEN)

LOOKUP (search, match, and look up values, like Excel's functions INDEX + MATCH)

(2) Multivariate Computation

RECODE (recode a variable)

RESCALE (rescale a variable; e.g., from 5-point to 7-point scale)

SUM (compute multivariate sum)

MEAN (compute multivariate mean)

STD (compute multivariate standard deviation)

MODE (compute multivariate mode)

COUNT (count values across variables)

CONSEC (count "consecutive identical digits" across variables)

(3) Reliability and Validity Analysis

Alpha (reliability analysis, Cronbach's \(\alpha\))

EFA (exploratory factor analysis)

CFA (confirmatory factor analysis)

(4) Multi-Factor ANOVA, Simple-Effect Analysis, and Post-Hoc Multiple Comparison

MANOVA (multi-factor between-subjects, within-subjects, and mixed design ANOVA)

EMMEANS (simple-effect analysis and post-hoc multiple comparison)

(5) Advanced Toolbox and Tidy Report of Statistical Models

grand_mean_center (center variable(s) on grand mean(s))

group_mean_center (center variable(s) on group mean(s))

regress (fast perform OLS, logistic, poisson, and multilevel regression analyses)

GLM_summary (advanced report of general/generalized linear models)

HLM_summary (advanced report of multilevel/hierarchical linear models)

model_summary (tidy report of regression models)

med_summary (tidy report of mediation analyses based on the mediation package)

ccf_plot (cross-correlation analysis with a ggplot2 plot)

granger_test (Granger causality test based on the lmtest::grangertest function)

(6) Theme for ggplot2

theme_bruce (a set of nice themes for scientific publication)