Permalink
Browse files

added sig_symbols argument to anova.afex_aov. Several changes to acco…

…modate new printing of sig_symbols. Added default to nice.mixed()
  • Loading branch information...
1 parent ca3b8bc commit 25a3c7087e1bcdd2b4eebbbf7bafeb003906cfd8 @singmann committed Apr 6, 2017
Showing with 36 additions and 24 deletions.
  1. +3 −3 DESCRIPTION
  2. +1 −0 NAMESPACE
  3. +2 −2 R/afex-package.R
  4. +1 −0 R/helpers.R
  5. +6 −5 R/methods.afex_aov.R
  6. +2 −2 R/nice.R
  7. +2 −2 dev.R
  8. +3 −1 examples/examples.nice.R
  9. +2 −2 man/afex-package.Rd
  10. +5 −2 man/afex_aov-methods.Rd
  11. +1 −0 man/afex_options.Rd
  12. +8 −5 man/nice.Rd
View
@@ -2,7 +2,7 @@ Package: afex
Type: Package
Title: Analysis of Factorial Experiments
Depends: R (>= 3.1.0), lme4 (>= 1.1-8), lsmeans (>= 2.17)
-Suggests: ascii, xtable, parallel, plyr, optimx, nloptr, knitr, rmarkdown, lattice,
+Suggests: xtable, parallel, plyr, optimx, nloptr, knitr, rmarkdown, lattice,
latticeExtra, multcomp, testthat, mlmRev, dplyr, tidyr, dfoptim, Matrix
Imports: stringr, coin, pbkrtest (>= 0.4-1), lmerTest, car, reshape2, stats, methods
Description: Provides convenience functions for analyzing factorial experiments using
@@ -28,6 +28,6 @@ Authors@R: c(person(given="Henrik", family="Singmann", role=c("aut", "cre"),
role=c("ctb")), person(given="Michael A.", family="Lawrence", role=c("ctb")),
person(given="Ulf", family="Mertens", role=c("ctb")),
person(given="Jonathan", family="Love", role=c("ctb")) )
-Version: 0.17-5
-Date: 2017-04-03
+Version: 0.17-6
+Date: 2017-04-06
RoxygenNote: 6.0.1
View
@@ -69,6 +69,7 @@ importFrom(stats,model.matrix)
importFrom(stats,optim)
importFrom(stats,p.adjust)
importFrom(stats,setNames)
+importFrom(stats,symnum)
importFrom(stats,t.test)
importFrom(stats,terms)
importFrom(stats,update)
View
@@ -3,8 +3,8 @@
#' \tabular{ll}{
#' Package: \tab afex\cr
#' Type: \tab Package\cr
-#' Version: \tab 0.17-5\cr
-#' Date: \tab 2017-04-03\cr
+#' Version: \tab 0.17-6\cr
+#' Date: \tab 2017-04-06\cr
#' Depends: \tab R (>= 3.1.0), lme4 (>= 1.1-8), lsmeans (>= 2.17)\cr
#' Encoding: \tab UTF-8\cr
#' License: \tab GPL (>=2)\cr
View
@@ -13,6 +13,7 @@
#' \item \code{es_aov}: Effect size reported for ANOVAs (see \code{\link{aov_car}}), default is \code{"ges"} (generalized eta-squared).
#' \item \code{correction_aov}: Correction used for within-subjects factors with more than two levels for ANOVAs (see \code{\link{aov_car}} or \code{\link{nice}}), default is \code{"GG"} (Greenhouse-Geisser correction). (ANOVA functions only)
#' \item \code{factorize}: Should between subject factors be factorized (with note) before running the analysis? Default is \code{TRUE}. (ANOVA functions only)
+#' \item \code{sig_symbols}: Default significant symbols used for ANOVA and \code{mixed} printing. Default is\code{c(" +", " *", " **", " ***")}.
#' \item \code{lmer_function}: Which \code{lmer} function should \code{mixed} or \code{lmer_alt} use. The default is \code{"lmerTest"} which uses \code{\link[lmerTest]{lmer}}, \code{"lme4"} is also possible which uses \code{\link[lme4]{lmer}}. There should be no difference between the two. The latter could be minimally faster, but does not allow to use \code{lmerTest::anova()}.
#' }
#'
View
@@ -21,7 +21,7 @@
#' \code{p_adjust_method} defaults to the method specified in the call to \code{\link{aov_car}} in \code{anova_table}. If no method was specified and \code{p_adjust_method = NULL} p-values are not adjusted.
#'
#' @references
-#' Cramer, A. O. J., van Ravenzwaaij, D., Matzke, D., Steingroever, H., Wetzels, R., Grasman, R. P. P. P., ... Wagenmakers, E.-J. (2015). Hidden multiplicity in exploratory multiway ANOVA: Prevalence and remedies. \emph{Psychonomic Bulletin & Review}, 18. doi:\href{http://doi.org/10.3758/s13423-015-0913-5}{10.3758/s13423-015-0913-5}
+#' Cramer, A. O. J., van Ravenzwaaij, D., Matzke, D., Steingroever, H., Wetzels, R., Grasman, R. P. P. P., ... Wagenmakers, E.-J. (2015). Hidden multiplicity in exploratory multiway ANOVA: Prevalence and remedies. \emph{Psychonomic Bulletin & Review}, 1-8. doi:\href{http://doi.org/10.3758/s13423-015-0913-5}{10.3758/s13423-015-0913-5}
#'
#' @name afex_aov-methods
#' @importFrom stats p.adjust
@@ -33,7 +33,7 @@ NULL
#' @inheritParams nice
#' @method anova afex_aov
#' @export
-anova.afex_aov <- function(object, es = afex_options("es_aov"), observed = NULL, correction = afex_options("correction_aov"), MSE = TRUE, intercept = FALSE, p_adjust_method = NULL, ...) {
+anova.afex_aov <- function(object, es = afex_options("es_aov"), observed = NULL, correction = afex_options("correction_aov"), MSE = TRUE, intercept = FALSE, p_adjust_method = NULL, sig_symbols = afex_options("sig_symbols"), ...) {
# internal functions:
# check arguments
dots <- list(...)
@@ -113,18 +113,19 @@ anova.afex_aov <- function(object, es = afex_options("es_aov"), observed = NULL,
attr(anova_table, "es") <- es
attr(anova_table, "correction") <- if(length(attr(object, "within")) > 0 && any(vapply(object$data$long[, attr(object, "within"), drop = FALSE], nlevels, 0) > 2)) correction else "none"
attr(anova_table, "observed") <- if(!is.null(observed) & length(observed) > 0) observed else character(0)
- attr(anova_table, "sig_symbols") <- if(!is.null(dots$sig_symbols)) dots$sig_symbols else afex_options("sig_symbols")
+ attr(anova_table, "sig_symbols") <- if(!is.null(sig_symbols)) sig_symbols else afex_options("sig_symbols")
anova_table
}
#' @rdname afex_aov-methods
#' @method print afex_aov
+#' @importFrom stats symnum
#' @export
print.afex_aov <- function(x, ...) {
out <- nice(x$anova_table, ...)
print(out)
-
- sleg <- paste(paste(c(0, 0.001, 0.01, 0.05, 0.1), rev(paste0("", c(" ", gsub(" ", "", attr(x$anova_table, "sig_symbols"))), "")), collapse = " "), 1)
+ sleg <- attr(symnum(0, cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
+ symbols = rev(c(" " ,stringr::str_trim(attr(x$anova_table, "sig_symbols"))))), "legend")
width <- getOption("width")
if(width < nchar(sleg)) {
View
@@ -8,7 +8,7 @@
#' @param observed character vector referring to the observed (i.e., non manipulated) variables/effects in the design. Important for calculation of generalized eta-squared (ignored if \code{es} is not \code{"ges"}), see details.
#' @param correction Character. Which sphericity correction of the degrees of freedom should be reported for the within-subject factors. The default is given by \code{afex_options("correction_aov")}, which is initially set to \code{"GG"} corresponding to the Greenhouse-Geisser correction. Possible values are \code{"GG"}, \code{"HF"} (i.e., Hyunh-Feldt correction), and \code{"none"} (i.e., no correction).
#' @param p_adjust_method \code{character} indicating if p-values for individual effects should be adjusted for multiple comparisons (see \link[stats]{p.adjust} and details). The default \code{NULL} corresponds to no adjustment.
-#' @param sig_symbols Character. What should be the symbols designating significance? When entering an vector with \code{length(sig.symbol) < 4} only those elements of the default (\code{c(" +", " *", " **", " ***")}) will be replaced. \code{sig_symbols = ""} will display the stars but not the \code{+}, \code{sig_symbols = rep("", 4)} will display no symbols.
+#' @param sig_symbols Character. What should be the symbols designating significance? When entering an vector with \code{length(sig.symbol) < 4} only those elements of the default (\code{c(" +", " *", " **", " ***")}) will be replaced. \code{sig_symbols = ""} will display the stars but not the \code{+}, \code{sig_symbols = rep("", 4)} will display no symbols. The default is given by \code{afex_options("sig_symbols")}.
#' @param MSE logical. Should the column containing the Mean Sqaured Error (MSE) be displayed? Default is \code{TRUE}.
#' @param intercept logical. Should intercept (if present) be included in the ANOVA table? Default is \code{FALSE} which hides the intercept.
#' @param sig.symbols deprecated argument, only for backwards compatibility, use \code{"sig_symbols"} instead.
@@ -140,7 +140,7 @@ is.wholenumber <- function(x, tol = .Machine$double.eps^0.5) abs(x - round(x))
#' @rdname nice
#' @method nice mixed
#' @export
-nice.mixed <- function(object, sig_symbols = c(" +", " *", " **", " ***"), ...) {
+nice.mixed <- function(object, sig_symbols = afex_options("sig_symbols"), ...) {
anova_table <- object$anova_table
dots <- list(...)
if("sig.symbols" %in% names(dots)) { #(!missing(sig.symbols)) {
View
4 dev.R
@@ -36,7 +36,7 @@ R.libs <- "./packages/library"
closeAllConnections()
roxy.package(
pck.source.dir = pkg.src.dir,
- pck.version = "0.17-5",
+ pck.version = "0.17-6",
pck.description = data.frame(
Package = "afex",
Type = "Package",
@@ -52,7 +52,7 @@ roxy.package(
person(given=\"Jonathan\", family=\"Love\", role=c(\"ctb\"))
)",
Depends = "R (>= 3.1.0), lme4 (>= 1.1-8), lsmeans (>= 2.17)",
- Suggests = "ascii, xtable, parallel, plyr, optimx, nloptr, knitr, rmarkdown, lattice, latticeExtra, multcomp, testthat, mlmRev, dplyr, tidyr, dfoptim, Matrix",
+ Suggests = "xtable, parallel, plyr, optimx, nloptr, knitr, rmarkdown, lattice, latticeExtra, multcomp, testthat, mlmRev, dplyr, tidyr, dfoptim, Matrix",
Imports = "stringr, coin, pbkrtest (>= 0.4-1), lmerTest, car, reshape2, stats, methods",
Description = "Provides convenience functions for analyzing factorial experiments using ANOVA or mixed models. aov_ez(), aov_car(), and aov_4() allow specification of between, within (i.e., repeated-measures), or mixed between-within (i.e., split-plot) ANOVAs for data in long format (i.e., one observation per row), potentially aggregating multiple observations per individual and cell of the design. mixed() fits mixed models using lme4::lmer() and computes p-values for all fixed effects using either Kenward-Roger or Satterthwaite approximation for degrees of freedom (LMM only), parametric bootstrap (LMMs and GLMMs), or likelihood ratio tests (LMMs and GLMMs). afex uses type 3 sums of squares as default (imitating commercial statistical software).",
URL = "http://afex.singmann.science/, https://github.com/singmann/afex",
View
@@ -4,7 +4,9 @@
data(md_12.1)
# create object of class afex_aov:
rmd <- aov_ez("id", "rt", md_12.1, within = c("angle", "noise"))
+rmd
nice(rmd)
+str(nice(rmd))
# use different es:
nice(rmd, es = "pes") # noise: .82
nice(rmd, es = "ges") # noise: .39
@@ -23,7 +25,7 @@ tmp.aov <- aov_car(value ~ treatment * gender + Error(id/phase*hour), data = obk
nice(tmp.aov, observed = "gender")
-nice(tmp.aov, observed = "gender", sig.symbols = rep("", 4))
+nice(tmp.aov, observed = "gender", sig_symbols = rep("", 4))
\dontrun{
# use package ascii or xtable for formatting of tables ready for printing.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 25a3c70

Please sign in to comment.