diff --git a/NEWS.md b/NEWS.md index 02d24a095..ae3ed53ff 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,8 +2,9 @@ # pillar 1.9.0.9008 -- Internal changes only. +## Bug fixes +- Math operations on `num()` objects now pass additional arguments to the mathematical function (@gvelasq, #660). # pillar 1.9.0.9007 diff --git a/R/num.R b/R/num.R index 00dfeb66c..81179e10a 100644 --- a/R/num.R +++ b/R/num.R @@ -127,7 +127,7 @@ vec_arith.numeric.pillar_num <- vec_arith.pillar_num.default vec_math.pillar_num <- function(.fn, .x, ...) { "!!!!DEBUG vec_math(`v(.fn)`)" - out <- vec_math_base(.fn, vec_proxy(.x)) + out <- vec_math_base(.fn, vec_proxy(.x), ...) if (is.numeric(out)) { out <- vec_restore(out, .x) diff --git a/tests/testthat/_snaps/num.md b/tests/testthat/_snaps/num.md index e4d684c4b..e9a0473c2 100644 --- a/tests/testthat/_snaps/num.md +++ b/tests/testthat/_snaps/num.md @@ -467,6 +467,11 @@ Output [1] 84.1 90.9 14.1 + Code + sum(num(c(1:3, NA)), na.rm = TRUE) + Output + + [1] 6 # formatting diff --git a/tests/testthat/test-num.R b/tests/testthat/test-num.R index 759bbb271..dd207ad48 100644 --- a/tests/testthat/test-num.R +++ b/tests/testthat/test-num.R @@ -170,6 +170,7 @@ test_that("mathematics", { min(num(1:3, label = "$")) mean(num(1:3, notation = "eng")) sin(num(1:3, label = "%", scale = 100)) + sum(num(c(1:3, NA)), na.rm = TRUE) }) })