This is really esoteric but caused a test of mine to fail in a very puzzling way. Dates created by readr are different from those created all other ways (integer vs double).
library(readr)
xbase <- data.frame(d = as.Date(c("2016-02-02", NA)))
xdplyr <- dplyr::data_frame(d = as.Date(c("2016-02-02", NA)))
xreadr <- read_csv("d\n2016-02-02\nNA")
These appear to be the same, up to tbl_df-ness.
str(xbase)
#> 'data.frame': 2 obs. of 1 variable:
#> $ d: Date, format: "2016-02-02" NA
str(xdplyr)
#> Classes 'tbl_df', 'tbl' and 'data.frame': 2 obs. of 1 variable:
#> $ d: Date, format: "2016-02-02" NA
str(xreadr)
#> Classes 'tbl_df', 'tbl' and 'data.frame': 2 obs. of 1 variable:
#> $ d: Date, format: "2016-02-02" NA
But the readr product stores its dates as integer vs numeric for the other two.
dput(xbase[2, , drop = FALSE])
#> structure(list(d = structure(NA_real_, class = "Date")), .Names = "d", row.names = 2L, class = "data.frame")
dput(xdplyr[2, ])
#> structure(list(d = structure(NA_real_, class = "Date")), .Names = "d", class = c("tbl_df",
#> "data.frame"), row.names = c(NA, -1L))
dput(xreadr[2, ])
#> structure(list(d = structure(NA_integer_, class = "Date")), .Names = "d", class = c("tbl_df",
#> "data.frame"), row.names = c(NA, -1L))
And it means even testthat::expect_equivalent() fails.
testthat::expect_equivalent(xdplyr, xreadr)
#> Error: xdplyr not equal to expected
#> Rows in x but not y: 2. Rows in y but not x: 2.
This is really esoteric but caused a test of mine to fail in a very puzzling way. Dates created by
readrare different from those created all other ways (integer vs double).These appear to be the same, up to
tbl_df-ness.But the
readrproduct stores its dates as integer vs numeric for the other two.And it means even
testthat::expect_equivalent()fails.