dplyr::lag
works fine with integers with the first entry being <NA>
, but with bit64::integer64
the first entry is a huge number.
This is my setting:
library(tidyverse)
library(magrittr)
#> ...
library(bit64)
#> Loading required package: bit
#> Attaching package bit
#> ...
#> Attaching package bit64
#> ...
#> The following object is masked from 'package:bit':
#>
#> still.identical
#> The following objects are masked from 'package:base':
#>
#> :, %in%, is.double, match, order, rank
library(reprex)
sessionInfo()
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-apple-darwin18.6.0 (64-bit)
#> Running under: macOS Mojave 10.14.6
#>
#> ...
#>
#> other attached packages:
#> [1] reprex_0.3.0 bit64_0.9-7 bit_1.1-14 magrittr_1.5
#> [5] forcats_0.4.0 stringr_1.4.0 dplyr_0.8.1 purrr_0.3.2
#> [9] readr_1.3.1 tidyr_0.8.3 tibble_2.1.3 ggplot2_3.2.0
#> [13] tidyverse_1.2.1
#>
#> ...
Here is a minimal reprex:
tib_int64 <- tibble(A_int = as.integer(c(1,2,3)),
A_int64 = as.integer64(c(1,2,3)))
tib_int64 %>% mutate(B = lag(A_int), C = lag(A_int64))
#> # A tibble: 3 x 4
#> A_int A_int64 B C
#> <int> <int64> <int> <int64>
#> 1 1 1 NA 9218868437227407266
#> 2 2 2 1 1
#> 3 3 3 2 2
The first entry in the C
column should be <NA>
like in the B
column.
Is this a dplyr
problem or a bit64
problem?
This is not too difficult to work around, but shouldn't this be filed as a bug?