From 0291cfd89a9ed3f83bc1720e69445c2b70cb9d99 Mon Sep 17 00:00:00 2001 From: "Isaac T. Petersen" Date: Sun, 24 Apr 2022 12:36:29 -0500 Subject: [PATCH] account for change to `decimals = 0` for format() in R 4.1 Related to this issue: https://github.com/doomlab/MOTE/issues/9 --- R/apa.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/apa.R b/R/apa.R index c183235..15c6343 100755 --- a/R/apa.R +++ b/R/apa.R @@ -30,7 +30,8 @@ apa <- function(value, decimals = 3, leading = TRUE) { } if (leading == T) { - formnumber <- format(round(as.numeric(value), decimals), digits = decimals, nsmall = decimals) + sigDigits <- decimals + 1 + formnumber <- format(round(as.numeric(value), decimals), digits = sigDigits, nsmall = decimals) } if (leading == F) { formnumber <- sub("^(-?)0.", "\\1.", sprintf(paste("%.", decimals, "f", sep = ""), as.numeric(value)))