tidyverse/vroom

Integer is loaded as double

kadyb opened this issue · 3 comments

kadyb commented
library("vroom")

df = data.frame(x = 1:100)
typeof(df$x)
#> [1] "integer"
tmp = tempfile(fileext = ".csv")
write.csv(df, tmp, row.names = FALSE)

df = vroom(tmp, delim = ",")
typeof(df$x)
#> [1] "double"

df = utils::read.csv(tmp)
typeof(df$x)
#> [1] "integer"

Interestingly I think vroom actually hardcodes its ability to guess types as integers to false

auto type = guess_type__(col_vals, na, locale_info.get(), false);

From readr v1.2.0 on, readr has never guessed integer https://readr.tidyverse.org/news/index.html?q=guess#readr-120.

And, I assume, vroom simply never guessed integer.

IIRC, in both readr and vroom, if you want integer, you have to specify it explicitly.

I'm quite sure this is an intentional design decision that came from hard lessons learned in readr.