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 where the current file is, print strings with rich formats and colors); (2) multivariate computation (e.g., compute scale sums/means/… with reverse scoring); (3) reliability and factor analyses; (4) descriptive statistics and correlation analyses; (5) multi-factor analysis of variance (ANOVA), simple-effect analysis, and post-hoc multiple comparison; (6) tidy report of regression models and other results (to R Console and MS Word); (7) mediation and moderation analyses (PROCESS); and (8) additional toolbox for statistics and graphics.
E-mail: baohws@foxmail.com
Website: psychbruce.github.io
ResearchGate | GitHub | 知乎
## 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:
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]:
bruceR
Basic R Programming
set.wd()
pkg_depend()
, pkg_install_suggested()
formatF()
, formatN()
Print()
, Glue()
, Run()
%^%
%notin%
%allin%
, %anyin%
, %nonein%
, %partin%
Multivariate Computation
SUM()
, MEAN()
, STD()
, MODE()
, COUNT()
, CONSEC()
RECODE()
, RESCALE()
LOOKUP()
Reliability and Factor analyses
Alpha()
EFA()
CFA()
Descriptive Statistics and Correlation Analyses
Describe()
Freq()
Corr()
cor_diff()
Multi-Factor ANOVA, Simple-Effect Analysis, and Post-Hoc Multiple Comparison
MANOVA()
EMMEANS()
Tidy Report of Regression Models
model_summary()
GLM_summary()
HLM_summary()
HLM_ICC_rWG()
regress()
Mediation and Moderation Analyses
PROCESS()
lavaan_summary()
med_summary()
Additional Toolbox for Statistics and Graphics
grand_mean_center()
group_mean_center()
ccf_plot()
granger_test()
granger_causality()
theme_bruce()
show_colors()
Some functions in bruceR
allow table output to Microsoft Word (by setting file="xxx.doc"
in the function).
bruceR Function | Output: R Console | Output: MS Word |
---|---|---|
print_table() |
√ | √ (basic usage) |
Describe() |
√ | √ |
Freq() |
√ | √ |
Corr() |
√ | √ (recommended) |
Alpha() |
√ | |
EFA() |
√ | |
CFA() |
√ | |
MANOVA() |
√ | √ |
EMMEANS() |
√ | |
PROCESS() |
√ | √ (only a part) |
model_summary() |
√ | √ (recommended) |
med_summary() |
√ | √ |
lavaan_summary() |
√ | |
GLM_summary() |
√ | |
HLM_summary() |
√ | |
HLM_ICC_rWG() |
√ | |
granger_test() |
√ | |
granger_causality() |
√ | √ |
Examples:
## Correlation analysis (and descriptive statistics)
Corr(airquality, file="cor.doc")
## Regression analysis
lm1=lm(Temp ~ Month + Day, data=airquality)
lm2=lm(Temp ~ Month + Day + Wind + Solar.R, data=airquality)
model_summary(list(lm1, lm2), file="reg.doc")
model_summary(list(lm1, lm2), std=TRUE, file="reg_std.doc")