An edge case, but an easy fix. Replace seq_along() with vec_seq_along() in with_order()
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
df <- tibble(a = c(1, 1, 2), b = c(2, 1, 1))
# Should be `c(2, NA, 1)`
with_order(order_by = df, fun = lag, x = 1:3)
#> [1] 2 NA
Created on 2022-07-15 by the reprex package (v2.0.1)
An edge case, but an easy fix. Replace
seq_along()withvec_seq_along()inwith_order()Created on 2022-07-15 by the reprex package (v2.0.1)