diff --git a/R/p_direction.R b/R/p_direction.R index 1199822f9..6e5585f3b 100644 --- a/R/p_direction.R +++ b/R/p_direction.R @@ -499,6 +499,6 @@ as.double.p_direction <- as.numeric.p_direction #' @method format p_direction #' @rdname p_direction #' @export -format.p_direction <- function(x, as_percent = TRUE, ...) { - insight::format_value(as.numeric(x), as_percent = as_percent, ...) +format.p_direction <- function(x, digits = 2, as_percent = TRUE, ...) { + insight::format_value(as.numeric(x), digits = digits, as_percent = as_percent, ...) } diff --git a/man/p_direction.Rd b/man/p_direction.Rd index 845713e27..8e2fd9e30 100644 --- a/man/p_direction.Rd +++ b/man/p_direction.Rd @@ -48,7 +48,7 @@ pd(x, ...) \method{p_direction}{BFBayesFactor}(x, method = "direct", null = 0, ...) -\method{format}{p_direction}(x, as_percent = TRUE, ...) +\method{format}{p_direction}(x, digits = 2, as_percent = TRUE, ...) } \arguments{ \item{x}{Vector representing a posterior distribution. Can also be a Bayesian @@ -79,6 +79,13 @@ filtered by default, so only parameters that typically appear in the \code{summary()} are returned. Use \code{parameters} to select specific parameters for the output.} +\item{digits}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} + \item{as_percent}{Logical, if \code{TRUE}, value is formatted as percentage value.} } diff --git a/tests/testthat/test-p_direction.R b/tests/testthat/test-p_direction.R index df7fbe3cc..41c7373ae 100644 --- a/tests/testthat/test-p_direction.R +++ b/tests/testthat/test-p_direction.R @@ -52,5 +52,5 @@ test_that("p_direction, formatting", { expect_identical(out, "51.70%") # out <- data.frame(p) - # out <- print(data.frame(p)) + # print(data.frame(p)) })