readr
readr copied to clipboard
type_convert() does not parse IEEE 754 double values (NaN, Inf, -Inf)
Loading a csv with NaN, Inf, -Inf values with col_double() works as expected (#1225):
read_csv("a\nNaN\nInf\n-INF", col_types = cols(a=col_double()))
## A tibble: 3 × 1
# a
# <dbl>
#1 NaN
#2 Inf
#3 -Inf
But a similar type_convert() throws errors, and loads all the special values as NA:
type_convert(tibble(a=c("NaN", "Inf", "-INF")), col_types = cols(a=col_double()))
## A tibble: 3 × 1
# a
# <dbl>
#1 NA
#2 NA
#3 NA
#Warning messages:
#1: [0, 1]: expected a double, but got 'NaN'
#2: [1, 1]: expected a double, but got 'Inf'
#3: [2, 1]: expected a double, but got '-INF'
Is this the intended behavior? Or an artifact of v1 vs v2 (#1277)? Thanks!