diff --git a/.Rbuildignore b/.Rbuildignore index 4a64ed31..95d095a9 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -21,3 +21,4 @@ ^vignettes/papaja.tex$ ^CRAN-SUBMISSION$ ^revdep$ +^.luarc.json$ diff --git a/DESCRIPTION b/DESCRIPTION index c8428392..17023101 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -28,7 +28,7 @@ Imports: knitr (>= 1.26), methods, rmarkdown (>= 2.4), - rmdfiltr (>= 0.1.3), + rmdfiltr (>= 0.1.5), utils, yaml, zip diff --git a/R/apa_interval.R b/R/apa_interval.R index a8e16e01..2c60f09e 100644 --- a/R/apa_interval.R +++ b/R/apa_interval.R @@ -35,20 +35,19 @@ #' apa_confint(confint(lm(cars))) #' apa_confint(confint(lm(cars)), digits = 3) -apa_interval <- function( - x - , conf.int = NULL - , interval_type = NULL - , enclose_math = FALSE - , ... -) { - sapply(x, validate, name = "x", check_class = "numeric", check_infinite = FALSE) - validate(enclose_math, check_class = "logical", check_length = 1) - if(!is.null(interval_type)) validate(interval_type, check_class = "character", check_length = 1) +apa_interval <- function(x, ...) { + ellipsis <- list(...) + enclose_math <- ellipsis$enclose_math + interval_type <- ellipsis$interval_type + conf.int <- ellipsis$conf.int + + sapply(x, validate, name = "x", check_class = "numeric", check_infinite = FALSE) + if(!is.null(enclose_math)) validate(enclose_math, check_class = "logical", check_length = 1) + if(!is.null(interval_type)) validate(interval_type, check_class = "character", check_length = 1) - if(!is.null(conf.int)) validate(conf.int, check_class = "numeric", check_length = 1, check_range = c(0, 100)) + if(!is.null(conf.int)) validate(conf.int, check_class = "numeric", check_length = 1, check_range = c(0, 100)) - UseMethod("apa_interval", x) + UseMethod("apa_interval", x) } #' @rdname apa_interval @@ -70,10 +69,10 @@ apa_interval.default <- function(x, ...) { apa_interval.numeric <- function( x , y = NULL + , ... , conf.int = NULL , interval_type = NULL , enclose_math = FALSE - , ... ) { ellipsis_ci <- deprecate_ci(conf.int = conf.int, ...) conf.int <- ellipsis_ci$conf.int @@ -145,10 +144,10 @@ apa_interval.numeric <- function( apa_interval.matrix <- function( x + , ... , conf.int = NULL , interval_type = NULL , enclose_math = FALSE - , ... ) { ellipsis_ci <- deprecate_ci(conf.int = conf.int, ...) conf.int <- ellipsis_ci$conf.int @@ -218,13 +217,19 @@ apa_interval.matrix <- function( apa_interval.data.frame <- function( x + , ... , conf.int = NULL , interval_type = NULL , enclose_math = FALSE - , ... ) { x <- as.matrix(x) - apa_interval(x, ...) + apa_interval( + x + , interval_type = interval_type + , conf.int = conf.int + , enclose_math = enclose_math + , ... + ) } #' @rdname apa_interval @@ -233,10 +238,10 @@ apa_interval.data.frame <- function( apa_interval.list <- function( x + , ... , conf.int = NULL , interval_type = NULL , enclose_math = FALSE - , ... ) { x <- as.data.frame(x) apa_interval(x, ...) @@ -248,12 +253,18 @@ apa_interval.list <- function( apa_confint <- function( x + , ... , conf.int = NULL , interval_type = "CI" , enclose_math = FALSE - , ... ) { - apa_interval(x, interval_type = interval_type, ...) + apa_interval( + x + , interval_type = interval_type + , conf.int = conf.int + , enclose_math = enclose_math + , ... + ) } #' @rdname apa_interval @@ -266,12 +277,18 @@ print_confint <- apa_confint apa_hdint <- function( x + , ... , conf.int = NULL , interval_type = "HDI" , enclose_math = FALSE - , ... ) { - apa_interval(x, interval_type = interval_type, ...) + apa_interval( + x + , interval_type = interval_type + , conf.int = conf.int + , enclose_math = enclose_math + , ... + ) } #' @rdname apa_interval diff --git a/R/apa_print_wsci.R b/R/apa_print_wsci.R index 6739624a..063f260d 100644 --- a/R/apa_print_wsci.R +++ b/R/apa_print_wsci.R @@ -25,11 +25,11 @@ apa_print.papaja_wsci <- function(x, ...) { "$M = " , apa_num(summary_wsci$mean, ...) , "$, " - , - apa_confint( - x = summary_wsci[, c("lower_limit", "upper_limit")] - , conf.int = attr(x, "Confidence level") - , ... + , apa_confint( + x = summary_wsci[, c("lower_limit", "upper_limit")] + , conf.int = attr(x, "Confidence level") + , enclose_math = TRUE + , ... ) ) ) diff --git a/man/apa_interval.Rd b/man/apa_interval.Rd index 240292d4..534014b7 100644 --- a/man/apa_interval.Rd +++ b/man/apa_interval.Rd @@ -13,85 +13,77 @@ \alias{print_hdint} \title{Typeset Interval Estimate} \usage{ -apa_interval( - x, - conf.int = NULL, - interval_type = NULL, - enclose_math = FALSE, - ... -) +apa_interval(x, ...) -print_interval( - x, - conf.int = NULL, - interval_type = NULL, - enclose_math = FALSE, - ... -) +print_interval(x, ...) \method{apa_interval}{numeric}( x, y = NULL, + ..., conf.int = NULL, interval_type = NULL, - enclose_math = FALSE, - ... + enclose_math = FALSE ) \method{apa_interval}{matrix}( x, + ..., conf.int = NULL, interval_type = NULL, - enclose_math = FALSE, - ... + enclose_math = FALSE ) \method{apa_interval}{data.frame}( x, + ..., conf.int = NULL, interval_type = NULL, - enclose_math = FALSE, - ... + enclose_math = FALSE ) \method{apa_interval}{list}( x, + ..., conf.int = NULL, interval_type = NULL, - enclose_math = FALSE, - ... + enclose_math = FALSE ) apa_confint( x, + ..., conf.int = NULL, interval_type = "CI", - enclose_math = FALSE, - ... + enclose_math = FALSE ) print_confint( x, + ..., conf.int = NULL, interval_type = "CI", - enclose_math = FALSE, - ... + enclose_math = FALSE ) -apa_hdint(x, conf.int = NULL, interval_type = "HDI", enclose_math = FALSE, ...) +apa_hdint(x, ..., conf.int = NULL, interval_type = "HDI", enclose_math = FALSE) print_hdint( x, + ..., conf.int = NULL, interval_type = "HDI", - enclose_math = FALSE, - ... + enclose_math = FALSE ) } \arguments{ \item{x}{Numeric. A vector (of length 2, unless \code{y} is also specified) with, a two-column \code{matrix}, or a \code{data.frame}, which can coerced to a \code{matrix}.} +\item{...}{Further arguments passed on to \code{\link[=apa_num]{apa_num()}}.} + +\item{y}{Numeric. An optional vector of the same length as \code{x}.} + \item{conf.int}{Numeric. Confidence level of the interval. Ignored if level can be inferred from attributes of \code{x}, see Details.} @@ -100,10 +92,6 @@ estimate, e.g. \code{CI}.} \item{enclose_math}{Logical. Indicates whether the interval should be enclosed in \code{$} (i.e., a math environment).} - -\item{...}{Further arguments passed on to \code{\link[=apa_num]{apa_num()}}.} - -\item{y}{Numeric. An optional vector of the same length as \code{x}.} } \value{ A single interval is returned as a \code{character} vector of length 1; diff --git a/tests/testthat/test_apa_print_wsci.R b/tests/testthat/test_apa_print_wsci.R index b5c90ccc..e0d711a3 100644 --- a/tests/testthat/test_apa_print_wsci.R +++ b/tests/testthat/test_apa_print_wsci.R @@ -23,7 +23,7 @@ test_that( ) expect_identical( apa_wsci$estimate$N0_P0 - , "$M = 51.717$, 98\\% CI [46.603, 56.831]" + , "$M = 51.717$, 98\\% CI $[46.603, 56.831]$" ) } ) diff --git a/tests/testthat/test_meta.R b/tests/testthat/test_meta.R index d9bcef45..bcf89355 100644 --- a/tests/testthat/test_meta.R +++ b/tests/testthat/test_meta.R @@ -6,8 +6,8 @@ test_that( lang <- papaja:::localize("english") expect_is(lang, "list") - expect_equal(length(lang), 9) - expect_equal(names(lang), c("author_note", "abstract", "keywords", "word_count", "table", "figure", "note", "correspondence", "email")) - expect_equivalent(sapply(lang, class), rep("character", 9)) + expect_equal(length(lang), 14) + expect_equal(names(lang), c("author_note", "abstract", "keywords", "word_count", "table", "figure", "note", "correspondence", "email", "version", "and", "cite_r_packages_s", "cite_r_packages_pl", "cite_r_footnote")) + expect_equivalent(sapply(lang, class), rep("character", 14)) } )