Please check the latest news (change log) and keep this package updated.
- Had to move
MuMIn
from "Imports" to "Suggests" due to its unresolved CRAN issues which need fixing before 2024-06-14. - Added
file
argument forEMMEANS()
to allow for saving the contrast table to MS Word.
- Now
var
anditems
support more flexible input, e.g.:.mean(var="X", items=1:3)
matchesX1
,X2
,X3
.mean(var="X.{any_placeholder}.pre", items=1:3)
matchesX.1.pre
,X.2.pre
,X.3.pre
- Use
\donttest{}
in more examples to avoid unnecessary errors.
- New function
cor_multilevel()
: Multilevel correlations (within-level and between-level). - Added arguments
pkg
andvalue.labels
forimport()
, providing more flexible settings and allowing for converting variables with value labels into R factors.
- Now use "YYYY.M" as package version number.
- Improved
Corr()
: Now it usesggplot2
to produce correlation plot. - Deprecated the argument
nsmall
for all functions. Now always usedigits
instead. (Both were acceptable in former versions.)
- Fixed
EMMEANS()
output when"d"
is used as a variable name.
- Changed the default packages to be loaded when
library(bruceR)
.
- Fixed new problems on CRAN: Restricted the number of "Imports" dependencies to 20. Changed welcome messages by using
packageStartupMessage()
so that the messages can be suppressed.
- Added
import()
support for importing URL-source data files and no-extension files.
- Fixed a trivial bug ("NOTE") about HTML5 for documentation pages.
- New
paired.d.type
argument forTTEST()
: Allow for specifying 3 types of Cohen's d for paired-samples t-test ("dz"
,"dav"
, and"drm"
). See Lakens (2013) for details.-
"dz"
(d for standardized difference)$$\text{Cohen's } d_{z} = \frac{M_{diff}}{SD_{diff}}$$ -
"dav"
(d for average standard deviation)$$\text{Cohen's } d_{av} = \frac{M_{diff}}{\frac{SD_{1} + SD_{2}}{2}}$$ -
"drm"
(d for repeated measures, corrected for correlation)$$\text{Cohen's } d_{rm} = \frac{M_{diff} \times \sqrt{2(1 - r_{1,2})}}{\sqrt{SD_{1}^2 + SD_{2}^2 - 2 \times r_{1,2} \times SD_{1} \times SD_{2}}}$$
-
- Moved necessary R packages (dependencies) from "Suggests" to "Imports", such that all dependencies will be automatically installed. Also added a check of dependencies when
library(bruceR)
.
- New functions
add()
andadded()
: Enhanced functions designed to create, modify, and/or delete variables. The functions combine the advantages of:=
(data.table),mutate()
(dplyr), andtransmute()
(dplyr). See help page for the usage and convenience. - New functions
.sum()
and.mean()
: Tidy version ofSUM()
andMEAN()
designed only foradd()
andadded()
. See help page for the usage and convenience.
- Improved warning information for
SUM()
,MEAN()
,EMMEANS()
.
- Rebuilt the package homepage (https://psychbruce.github.io/bruceR/) with
pkgdown
. Configuration is specified in_pkgdown.yml
. - Added an
R CMD check
workflow on GitHub, which checks the code for each push.
- Improved
cc()
. Now it becomes much more convenient! - Added a prompt message for the use of long data in
MANOVA()
: "Data are aggregated to mean (across items/trials) if there are >=2 observations per subject and cell. You may use Linear Mixed Model to analyze the data, e.g., with subjects and items as level-2 clusters." - Added
center
argument forPROCESS()
(default isTRUE
) for users who want to turn off the automatic grand-mean centering. However, mean centering is still highly suggested if one aim to obtain "main effect" rather than "fixed effect" (note: a fixed effect is not necessarily a main effect). - Added
estimator
argument forCFA()
(default is"ML"
) for users who want to use any other estimator (fixed issue #17).
- New function
cc()
: Split up a string (with separators) into a character vector (whitespace around separator is trimmed). For example,cc("A 1 , B 2 ; C 3 | D 4 \t E 5")
produces a vector ofc("A 1", "B 2", "C 3", "D 4", "E 5")
. The default separators include, ; | \n \t
. Users may also specify a separator.
-
Added a guideline and examples for creating interaction plots using the returned object of
MANOVA()
andEMMEANS()
. You can save the returned object and use theemmeans::emmip()
function to create an interaction plot (based on the fitted model and a formula specification). For usage, please see the help page ofemmeans::emmip()
. It returns an object of classggplot
, which can be easily modified and saved usingggplot2
syntax. -
Added an explanation of the automatic grand-mean centering in
PROCESS()
.
- Users who have not installed the
afex
package would see an unusual error when using theEMMEANS()
function (Error: $ operator is invalid for atomic vectors
). So nowafex
is again a strong dependency ofbruceR
, such that it is automatically installed when installingbruceR
. - Improved debugging information for
EMMEANS()
(whenmodel
is null). - Fixed a bug of interaction tests in
PROCESS()
when settingmod.type="3-way"
for multilevel models.
- Improved
print_table()
. - Changed symbol (for better output of R Markdown): ✔ (\u2714) → √ (\u221a).
- Fixed a small bug of direct effect output in
PROCESS()
for models without"x-y"
inmod.path
(e.g., Model 7). - Fixed a small bug when using
set.wd()
in an R Markdown file.
- Requiring R version 4.0+ again.
- Added automatic check for new version of
bruceR
whenlibrary(bruceR)
. - Added univariate tests (F) and multivariate tests (Pillai's trace and F) using
phia::testInteractions()
in the output ofEMMEANS()
. These tests produce identical results to those obtained with the SPSS GLM (/EMMEANS) syntax. - Improved the flexibility of
Freq()
: Now both vector and data frame can be used. For example, users may specify eitherFreq(data$variable)
orFreq(data, "variable")
. - Improved the output format of
GLM_summary()
andHLM_summary()
. - Deprecated two useless arguments of
HLM_summary()
:level2.predictors
andvartypes
. - Packages
lmerTest
,mediation
,interactions
, andlavaan
are now strong dependencies such that they would be installed when installingbruceR
. This also fixes an error when usingPROCESS()
without these packages installed.
- Fixed potential bugs in
print_table()
. - Fixed a bug of VIF results in
GLM_summary()
andHLM_summary()
when only one factor-type predictor with >= 3 levels is in a regression model. Other bugs in these two functions have also been fixed. - Fixed a bug of interaction tests in
PROCESS()
when settingmod.path="all"
in testing multilevel moderated mediation effects. Fixed another bug of CI output for direct effects when testing multilevel models.
- New function
TTEST()
: One-sample, independent-samples, and paired-samples t-test. Multiple dependent/independent variables can be tested simultaneously. It also tests the assumption of homogeneity of variance and allows users to determine whether variances are equal or not. Cohen's d and 95% CI are reported by default (see Details and Examples in its help page for an issue about the inconsistency in the results of 95% CI of Cohen's d between R packages). Bayes factor BF10 is also supported. Key results can be saved in APA format to MS Word. - New functions
import()
/export()
: Import/export data from/to a file with the two tidy functions, relieving users of the burden of remembering lots ofread_xxx()
/write_xxx()
functions. Many file formats are supported (especially .txt, .csv, .tsv, .psv, .xls, .xlsx, .sav, .dta, .rda, .rdata, and clipboard). Note that the two functions are inspired byrio::import()
/rio::export()
and have several modifications for more convenient use. Since this version, the packagerio
is no longer a strong dependency ofbruceR
and would not be loaded when loadingbruceR
.
-
Improved
MANOVA()
andEMMEANS()
:- Fixed several bugs.
- Modified the help pages.
- Improved output tables. Now all results are printed using
print_table()
. - Improved algorithm for estimating Cohen's d: Now it uses Root Mean Square Error (RMSE) as the pooled SD to estimate Cohen's d. Although there is disagreement on the estimation of pooled SD,
EMMEANS()
adopts this reasonable approach. If one usesMANOVA()
andEMMEANS()
to conduct the same t-test as using theTTEST()
function, the results will be identical. Indeed, the estimation methods of Cohen's d in t-tests are acknowledged. In computing pooled SD in ANOVAs, it uses (1) the square root of mean square error (MSE) for between-subjects designs and (2) the square root of mean variance of all paired differences of the residuals of repeated measures for within-subjects and mixed designs. In both situations, it extracts thelm
object from the returned value ofMANOVA()
. Then, it mainly uses thesigma()
andresiduals()
functions, respectively, to do these estimates. For source code, see R file on GitHub. Thus, the results of Cohen's d for designs with repeated measures are now different from those inbruceR
old versions (< 0.8.0), which indeed used an inappropriate method to compute pooled SD in such designs. - Added arguments (1)
ss.type
forMANOVA()
to specify either Type-II or Type-III Sum of Square; (2)aov.include
forMANOVA()
andmodel.type
forEMMEANS()
, for details, see the help pages. - Added warning messages for wrong usage of these functions. If observations are not uniquely identified in user-defined long-format data, the function takes averages across those multiple observations for each case (thanks to Xiangying Zou for reporting an infrequent bug related to this issue).
-
Improved
Alpha()
: Now it directly usespsych::alpha()
andpsych::omega()
, rather thanjmv::reliability()
, to perform reliability analysis. The format of result output has been changed and improved. -
Improved
EFA()
(almost completely rewritten): Now it directly usespsych::principal()
andpsych::fa()
, rather thanjmv::efa()
, to perform factor analysis (PCA or EFA). The format of result output has been changed and improved. MS Word output has been supported. A wrapper functionPCA()
has been added:EFA(..., method="pca")
. -
Improved
CFA()
andlavaan_summary()
: NowCFA()
only uses thelavaan::cfa()
, rather thanjmv:cfa()
, to build model, and then useslavaan_summary()
to present results. Forlavaan_summary()
, many bugs have been fixed, and the format of result table has been changed and improved. Both functions now support saving table to MS Word. -
Package dependencies: Much fewer strong dependencies, for faster and more robust installation. Removed
rio
andjmv
from dependencies. No longer loadrio
andpsych
whenlibrary(bruceR)
.
- Added an alias
set_wd()
forset.wd()
. - Improved
print_table()
: Fixed an issue of incorrect length of Chinese character output inprint_table()
. Between-column blanks are now 2 spaces (rather than 1 space) for a clearer presentation of table columns. - Modified onloading welcome messages.
- General bug-fixes and improvements.
- Added Word output for
lavaan_summary()
andgranger_test()
.
- Added the
digits
parameter as the equivalent to thensmall
parameter for all relevant functions. - Packages
mediation
,interactions
,MuMIn
, andtexreg
are now SUGGESTS rather than IMPORTS.
- Fixed a bug of value ordering for 3-way interaction (moderated moderation) in
PROCESS()
. - Fixed a bug for Word output in
Corr()
.
- New function
PROCESS()
: PROCESS for mediation, moderation, and conditional process (moderated mediation) analyses! This function supports a total of 24 kinds of SPSS PROCESS models (Hayes, 2018) and also supports multilevel mediation/moderation analyses. Overall, it supports the most frequently used types of mediation, moderation, moderated moderation (3-way interaction), and moderated mediation (conditional indirect effect) analyses for (generalized) linear or linear mixed models. Regression model summary and effect estimates (simple slopes and/or indirect effects) are printed in an elegant way. - New function
lavaan_summary()
: Tidy report of lavaan model.
- Improved many functions.
- Deprecated the
RANDBETWEEN()
function.
- Fixed a bug in the CRAN version 0.6.4 (a problem newly emerging on 2021-05-25).
- Added Word output (.doc) in
print_table()
and other functions usingprint_table()
inside:Describe()
,Freq()
,Corr()
,MANOVA()
,med_summary()
,granger_causality()
.
- Added a disclaimer about Cohen's d in the output and documentation of
EMMEANS()
: There is considerable disagreement on how to compute Cohen's d. Users should not take the default output as the only right results and are completely responsible for setting the "sd.pooled".
- Fixed bugs in
model_summary()
: (1) Model names withNULL
; (2) Multicollinearity check results withNULL
or other problems; (3) UTF-8 encoding problem in WPS software (no such problem in Microsoft Word).
- New function
granger_causality()
: Granger causality test (multivariate) based on vector autoregression (VAR) model. This function is an advanced and more general version of the functiongranger_test()
(bivariate). - Added logo (designed by @Meijia Li)
- Improved
set.wd()
: Now it usesrstudioapi::getSourceEditorContext()
to extract file path (even effective when running in R console), which only requires RStudio version >= 0.99.1111 and no longer has encoding problems (see release note in 0.6.1). - Improved
theme_bruce()
: Now it usesggtext::element_markdown()
to render Markdown/HTML rich text format, which can be used in plot text (e.g., titles). - Improved
EMMEANS()
: Now its results are always identical to those in SPSS (by settingmodel="multivariate"
inemmeans::joint_tests()
andemmeans::emmeans()
, which use thelm
ormlm
objects rather than theaov
object to perform tests). For a few cases with singular error matrix (i.e., some variables are linearly dependent), the results of simple-effect F tests will not be reported, but estimated marginal means and pairwise comparisons are not affected and so are still reported. Note that theEMMEANS
results in old versions ofbruceR
(version < 0.6.0) were identical to SPSS, but version 0.6.0 deprecated the parameterrepair
and no longer setmodel$aov=NULL
, which made the results not identical to SPSS (particularly for ANOVAs with repeated measures). In response to a user's feedback, now 0.6.2 has improved this function and makes its results accurate again.
- Improved function links in R documentation:
\code{\link[package:function]{package::function()}}
.
- Fixed a bug in
CFA()
(for lavaan-style output).
- New function
HLM_ICC_rWG()
: Tidy report of HLM indices "ICC(1)" (non-independence of data), "ICC(2)" (reliability of group means), and "rWG"/"rWG(J)" (within-group agreement for single-item/multi-item measures). - New function
Run()
: Run code parsed from text. - New function
show_colors()
: Show multiple colors (or a palette) in a plot. - New function
%^%
: Paste strings together (a wrapper ofpaste0()
).
- Improved
set.wd()
: Now it converts the extracted path string from "UTF-8" to "GBK" on Windows system to support paths including Chinese characters (otherwise, the path would become messy code and cause an error). Note that this problem does not exist on Mac OS. In addition, warning messages will be printed into the console if the user's RStudio version is lower than required (RStudio version >= 1.4.843 is required for a complete implementation of this function). - Improved
Alpha()
: Now it adds a parametervarrange
(to keep the same asSUM()
,MEAN()
, ...) and reports both Cronbach's α and McDonald's ω, with more detailed documentation.
Three ways to specify the variable list (implemented in the functions such as
SUM()
,MEAN()
,Alpha()
):1.
var + items
: use the common and unique parts of variable names. (e.g.,var="RSES", items=1:10, rev=c(3, 5, 8, 9, 10)
)2.
vars
: directly define the variable list. (e.g.,vars=c("E1", "E2", "E3", "E4", "E5"), rev=c("E1", "E2")
)3.
varrange
: use the start and end positions of the variable list. (e.g.,varrange="E1:E5", rev=c("E1", "E2")
)
- Added details about the package's contents in the Description field.
- Fixed a potential bug in
Corr()
(relevant to the changes inpsych::corr.test()
in a forthcoming release of thepsych
package).
- Formally published on CRAN!!!
- Passed R CMD check and Travis CI test:
0 errors √ | 0 warnings √ | 0 notes √
- New function
model_summary()
: Tidy report of (single/multiple) regression models (into console or to a Word/HTML file; supporting most types of models; based on thetexreg
package). - New function
med_summary()
: Tidy report of (simple/moderated) mediation analyses (based on themediation
package). - New function
ccf_plot()
: Cross-correlation analysis (plotting withggplot2
). - New function
granger_test()
: Granger test of predictive causality (based on thelmtest::grangertest()
function).
- Improved many major functions, especially
set.wd()
,Describe()
,Corr()
,MANOVA()
, andEMMEANS()
. - Tidy welcome messages when you
library(bruceR)
. - More packages for default loading (see details).
- Less packages for default installation (you can install all suggested packages by using the
pkg_install_suggested()
function).
- Changed package title and description of
bruceR
: BRoadly Useful Convenient and Efficient R functions that BRing Users Concise and Elegant R data analyses. - Reorganized raw code files.
- Fixed all bugs (errors, warnings, and notes) when conducting R CMD check.
- Fixed all problems in the manual inspection by CRAN team members.
- Deprecated some useless/defective functions (see details).
- Requiring R version 4.0+.
- Improved many functions.
- Fixed many bugs.
- Added citation information.
- General bug-fixes and improvements.
- New functions
MANOVA()
andEMMEANS()
: ANOVA, simple-effect analyses, and multiple comparisons (based on theafex
andemmeans
packages). - General bug-fixes and improvements.
- Added all help pages.
- General bug-fixes and improvements.
- Initial release on GitHub.