Skip to content

Commit

Permalink
Merge branch 'main' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
conig committed Oct 5, 2023
2 parents 8d2d770 + 27715f1 commit 850fa10
Show file tree
Hide file tree
Showing 76 changed files with 3,779 additions and 414 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
^cran-comments\.md$
^\.travis\.yml
^.github$
^example$
^inst/example$
^_config.yml$
^inst/papaja_manuscripts.bib
^inst/apa_source_files.csl
Expand All @@ -20,3 +20,4 @@
^vignettes/papaja.Rmd$
^vignettes/papaja.tex$
^CRAN-SUBMISSION$
^revdep$
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ If you think you have found a bug, please ensure your bug report includes all of
A clear and concise description of what the bug is.

**To Reproduce**
A [minimal complete verifiable example](https://stackoverflow.com/help/mcve) and the error message if applicable.
A [minimal complete verifiable example](https://stackoverflow.com/help/minimal-reproducible-example) and the error message if applicable.

**Expected behavior**
A clear and concise description of what you expected to happen.
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ on:
push:
branches:
- main
- master
- devel
pull_request:
branches:
- main
- master
- devel

name: R-CMD-check
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/no-response.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: No Response

on:
issue_comment:
types: [created]
schedule:
# Schedule 18:00 once every day
- cron: '0 18 * * *'

jobs:
noResponse:
runs-on: ubuntu-latest
steps:
- uses: lee-dohm/no-response@v0.5.0
with:
token: ${{ github.token }}
daysUntilClose: 28
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: papaja
Title: Prepare American Psychological Association Journal Articles with
R Markdown
Version: 0.1.1.9001
Version: 0.1.2.9000
Description: Tools to create dynamic, submission-ready manuscripts, which
conform to American Psychological Association manuscript guidelines. We
provide R Markdown document formats for manuscripts (PDF and Word) and
Expand All @@ -15,7 +15,7 @@ Authors@R: c(
, person("Joseph V.", "Casillas", email = "joseph.casillas@rutgers.edu", role = c("ctb"))
, person("Rudolf", "Siegel", email = "rudolf.siegel@uni-saarland.de", role = c("ctb"))
)
Date: 2022-07-04
Date: 2023-09-28
URL: https://github.com/crsh/papaja
BugReports: https://github.com/crsh/papaja/issues
Depends:
Expand All @@ -38,7 +38,7 @@ Suggests:
beeswarm,
boot,
car,
dplyr,
dplyr (>= 1.1.0),
effectsize (>= 0.4.4),
emmeans,
ggforce,
Expand All @@ -58,7 +58,7 @@ SystemRequirements: Rendering the document template requires
such as TinyTeX (>= 0.12; https://yihui.org/tinytex/)
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.2.2
RoxygenNote: 7.2.3
VignetteBuilder: knitr, R.rsp
Language: en-US
Roxygen: list(markdown = TRUE)
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2020
YEAR: 2023
COPYRIGHT HOLDER: Frederik Aust
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ S3method(apa_print,summary_emm)
S3method(apa_table,apa_results)
S3method(apa_table,apa_results_table)
S3method(apa_table,data.frame)
S3method(apa_table,default)
S3method(apa_table,list)
S3method(apa_table,matrix)
S3method(beautify_terms,character)
Expand Down
44 changes: 30 additions & 14 deletions R/add_custom_effect_sizes.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,39 @@ add_custom_effect_sizes.data.frame <- function(estimate, canonical_table, interc
}


add_custom_effect_sizes.function <- function(estimate, .x = NULL, observed = NULL, ...) {
add_custom_effect_sizes.function <- function(estimate, canonical_table, intercept = FALSE, .x = NULL, observed = NULL, ...) {

if(is.null(.x)) stop("Cannot apply custom effect-size function to this class of object.", call. = FALSE)

estimate_formals <- names(formals(estimate))
# print(estimate_formals)
if(any(estimate_formals == "observed")) {
add_custom_effect_sizes(estimate = estimate(.x, observed = observed), .x = .x, ...)
} else if(any(estimate_formals == "generalized")) {
add_custom_effect_sizes(estimate = estimate(.x, generalized = observed), .x = .x, ...)
} else if (!is.null(observed)) {
warning(
"Some terms have been specified as being observed, but the provided effect-size function does not seem to support observed terms."
, call. = FALSE
)
add_custom_effect_sizes(estimate = estimate(.x), .x = .x, ...)
} else {
add_custom_effect_sizes(estimate = estimate(.x), .x = .x, ...)

estimate_args <- list(
.x
)

if(length(observed)) {
if(any(estimate_formals == "observed")) estimate_args$observed <- observed
if(any(estimate_formals == "generalized")) estimate_args$generalized <- observed

# warnings
if(!any(estimate_formals == "observed") & !any(estimate_formals == "generalized")) {
warning(
"Some terms have been specified as being observed, but the provided effect-size function does not seem to support observed terms."
, call. = FALSE
)
}
}

if(isTRUE(intercept) & any(estimate_formals == "include_intercept")) {
estimate_args$include_intercept <- TRUE
message("Turning on intercept")
}


add_custom_effect_sizes(
estimate = do.call(what = estimate, args = estimate_args)
, canonical_table = canonical_table
, .x = .x
, ...
)
}
5 changes: 3 additions & 2 deletions R/apa6_formats.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
#' \href{ftp://ftp.fu-berlin.de/tex/CTAN/macros/latex/contrib/apa6/apa6.pdf}{documentation}
#' to find out about class options such as paper size or draft watermarks.
#'
#' Please refer to the \href{http://frederikaust.com/papaja_man/r-markdown-components.html#yaml-front-matter}{\pkg{papaja} online-manual}
#' Please refer to the \href{https://frederikaust.com/papaja_man/r-markdown-components.html#yaml-front-matter}{\pkg{papaja} online-manual}
#' for additional information on available YAML front matter settings.
#' Note that the available settings for DOCX documents are more limited
#' than for PDF documents.
#'
#' When creating PDF documents the output device for figures defaults to
#' \code{c("pdf", "png")}, so that each figure is saved in all four formats
#' at a resolution of 300 dpi.
#' @return R Markdown output format to pass to [rmarkdown::render()]
#' @return R Markdown output format to pass to [rmarkdown::render()].
#' @seealso [bookdown::pdf_document2()], [bookdown::word_document2()]
#' @export

Expand Down Expand Up @@ -437,6 +437,7 @@ pdf_pre_processor <- function(metadata, input_file, runtime, knit_meta, files_di
metadata$lang
, english = "en-EN"
, american = "en-US"
, german = "de-DE"
, metadata$lang
)
}
Expand Down
5 changes: 3 additions & 2 deletions R/apa_num.R
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,13 @@ print_p <- apa_p
#' should be determined for each element of `x` separately (the default),
#' or for the complete vector `x`.
#' @inherit apa_num return
#' @inheritParams base::formatC
#' @seealso [apa_num()], [apa_p()]
#' @examples
#' apa_df(c(1, 1.23151))
#' @export

apa_df <- function(x, digits = 2L, elementwise = TRUE) {
apa_df <- function(x, digits = 2L, big.mark = "", elementwise = TRUE) {

if(is.null(x)) return(NULL)
if(is.integer(x)) return(apa_num(x))
Expand All @@ -455,7 +456,7 @@ apa_df <- function(x, digits = 2L, elementwise = TRUE) {
digits <- 0L
}

apa_num(x, digits = digits)
apa_num(x, digits = digits, big.mark = big.mark)
}

#' @rdname apa_df
Expand Down
37 changes: 20 additions & 17 deletions R/apa_print_anova.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
#' @param estimate Character, function, or data frame. Determines which
#' estimate of effect size is to be used. See details.
#' @param mse Logical. Indicates if mean squared errors should be included in
#' output. The default is `TRUE`, but this can be changed either by supplying
#' a different value in the function call or by changing the global default
#' via `options(papaja.mse = FALSE)`.
#' output. The default is taken from the global option `getOption("papaja.mse")`.
#' It is `FALSE` if the \pkg{effectsize} package is installed and `TRUE` if it
#' is not installed. This can be changed either by supplying a different value
#' in the function call or by changing the global default via
#' `options(papaja.mse = ...)`.
#' @param observed Character. The names of the factors that are observed,
#' i.e., not manipulated. Necessary only for calculating *generalized* eta
#' squared; otherwise ignored. If `x` is of class `afex_aov`, `observed` is
Expand All @@ -30,9 +32,9 @@
#'
#' Argument `estimate` determines which measure of effect size is to be used:
#' It is currently possible to provide one of three characters to specify the
#' to-be-calculated effect size: \code{"ges"} for generalized \eqn{eta^2},
#' \code{"pes"} for partial \eqn{eta^2}, and \code{"es"} for \eqn{eta^2}.
#' Note that \eqn{eta^2} is calculated correctly if and only if the design is
#' to-be-calculated effect size: `"ges"` for generalized \eqn{\eta^2},
#' \code{"pes"} for partial \eqn{\eta^2}, and `"es"` for \eqn{\eta^2}.
#' Note that \eqn{\eta^2} is calculated correctly if and only if the design is
#' balanced.
#'
#' It is also possible to provide a `data.frame` with columns `estimate`,
Expand Down Expand Up @@ -69,7 +71,7 @@ apa_print.aov <- function(
, estimate = getOption("papaja.estimate_anova", "ges")
, observed = NULL
, intercept = FALSE
, mse = TRUE
, mse = getOption("papaja.mse", TRUE)
, in_paren = FALSE
, ...
) {
Expand All @@ -95,7 +97,7 @@ apa_print.summary.aov <- function(
, estimate = getOption("papaja.estimate_anova", "ges")
, observed = NULL
, intercept = FALSE
, mse = TRUE
, mse = getOption("papaja.mse", TRUE)
, in_paren = FALSE
, ...
) {
Expand All @@ -120,7 +122,7 @@ apa_print.aovlist <- function(
, estimate = getOption("papaja.estimate_anova", "ges")
, observed = NULL
, intercept = FALSE
, mse = TRUE
, mse = getOption("papaja.mse", TRUE)
, in_paren = FALSE
, ...
) {
Expand All @@ -146,7 +148,7 @@ apa_print.summary.aovlist <- function(
, estimate = getOption("papaja.estimate_anova", "ges")
, observed = NULL
, intercept = FALSE
, mse = TRUE
, mse = getOption("papaja.mse", TRUE)
, in_paren = FALSE
, ...
) {
Expand All @@ -172,10 +174,10 @@ apa_print.summary.aovlist <- function(
canonical_table = canonical_table
, .x = .x
, estimate = estimate
, mse = mse
, observed = observed
, intercept = intercept
)
if(isTRUE(mse)) canonical_table <- add_mse(canonical_table)

if(!intercept) canonical_table <- canonical_table[canonical_table$term != "(Intercept)", , drop = FALSE]

Expand Down Expand Up @@ -211,7 +213,7 @@ apa_print.Anova.mlm <- function(
, observed = NULL
, correction = getOption("papaja.sphericity_correction")
, intercept = FALSE
, mse = TRUE
, mse = getOption("papaja.mse", TRUE)
, in_paren = FALSE
, ...
) {
Expand Down Expand Up @@ -245,7 +247,7 @@ apa_print.summary.Anova.mlm <- function(
, observed = NULL
, correction = getOption("papaja.sphericity_correction")
, intercept = FALSE
, mse = TRUE
, mse = getOption("papaja.mse", TRUE)
, in_paren = FALSE
, ...
) {
Expand All @@ -263,11 +265,12 @@ apa_print.summary.Anova.mlm <- function(
canonical_table <- add_custom_effect_sizes(
canonical_table
, estimate = estimate
, mse = mse
, observed = observed
, intercept = intercept
, .x = .x
)
if(isTRUE(mse)) canonical_table <- add_mse(canonical_table)


# Remove intercept if the user doesn't want it:
if(!intercept) canonical_table <- canonical_table[canonical_table$term != "(Intercept)", , drop = FALSE]
Expand Down Expand Up @@ -305,7 +308,7 @@ apa_print.afex_aov <- function(
, observed = NULL
, correction = getOption("papaja.sphericity_correction")
, intercept = FALSE
, mse = TRUE
, mse = getOption("papaja.mse", TRUE)
, in_paren = FALSE
, ...
) {
Expand Down Expand Up @@ -374,7 +377,7 @@ apa_print.anova <- function(
, estimate = getOption("papaja.estimate_anova", "ges")
, observed = NULL
, intercept = FALSE
, mse = TRUE
, mse = getOption("papaja.mse", TRUE)
, in_paren = FALSE
# , conf.int = 0.95
, ...
Expand Down Expand Up @@ -489,11 +492,11 @@ apa_print.anova <- function(
canonical_table <- add_custom_effect_sizes(
estimate = estimate
, canonical_table = canonical_table
, mse = mse
, observed = observed
, intercept = intercept
, .x = .x
)
if(isTRUE(mse)) canonical_table <- add_mse(canonical_table)

if(!intercept) canonical_table <- canonical_table[canonical_table$term != "(Intercept)", , drop = FALSE]

Expand Down
4 changes: 2 additions & 2 deletions R/apa_print_emm_lsm.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ apa_print.summary_emm <- function(
if(is.null(adjust)) {
conf_level <- paste0(conf_level, "\\% CI")
} else {
conf_level <- paste0("$", conf_level, "\\%\\ \\mathrm{CI}_\\mathrm{\\scriptsize ", adjust["conf.int"], "}$")
conf_level <- paste0("$", conf_level, "\\%\\ \\mathrm{CI}_\\mathrm{\\scriptstyle ", adjust["conf.int"], "}$")
}
}

Expand Down Expand Up @@ -245,7 +245,7 @@ apa_print.summary_emm <- function(
variable_labels(tidy_x[[p_value]]) <- switch(
p_value
, "p.value" = "$p$"
, "adj.p.value" = paste0("$p_\\mathrm{\\scriptsize ", adjust["p.value"], "}$")
, "adj.p.value" = paste0("$p_\\mathrm{\\scriptstyle ", adjust["p.value"], "}$")
)
}

Expand Down

0 comments on commit 850fa10

Please sign in to comment.