Skip to content

Commit 341be94

Browse files
committed
refactor(growth_rate): preoptimize/normalize some ops
1 parent 393370f commit 341be94

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

R/growth_rate.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,10 @@ growth_rate <- function(
127127
if (length(x) != length(y)) cli_abort("`x` and `y` must have the same length.")
128128
method <- rlang::arg_match(method)
129129
assert_class(params, "growth_rate_params")
130-
if (any(is.na(x)) || any(is.na(x0))) {
130+
if (anyNA(x) || anyNA(x0)) {
131131
cli_abort("Neither `x` nor `x0` may contain `NA`s.")
132132
}
133-
dups <- duplicated(x)
134-
if (any(dups)) {
133+
if (vctrs::vec_duplicate_any(x)) {
135134
cli_abort(
136135
"`x` contains duplicate values. (If being run on a
137136
column in an `epi_df`, did you group by relevant key variables?)"

0 commit comments

Comments
 (0)