readr icon indicating copy to clipboard operation
readr copied to clipboard

`problems()` is empty when `col_select()` is on despite warnings

Open ginolhac opened this issue 8 months ago • 0 comments

Hello,

When col_select() is active, the problems() is empty while presence of a warning is correctly displayed. The following reprex shows the first column A contains a faulty character a that create a missing value when the col_types is set to integer.

Warning is correct and is dully visible when we call problems(tib).

however, if we remove the second column with a col_select() calling problems(tib2) returns nothing while it should.

Of note, read_delim() behaves the same.

R version: 4.4.3, {read}: v2.1.5.

library(readr)

input <- "
A,B
1,10
a,21"

tib <- read_csv(input, 
                col_types = cols(A = "i",
                                 B = "_"))
#> Warning: One or more parsing issues, call `problems()` on your data frame for details,
#> e.g.:
#>   dat <- vroom(...)
#>   problems(dat)
problems(tib)
#> # A tibble: 1 × 5
#>     row   col expected   actual file                            
#>   <int> <int> <chr>      <chr>  <chr>                           
#> 1     3     1 an integer a      /tmp/RtmpSinvUF/file4ddc2434d35c


tib2 <- read_csv(input, 
                col_types = cols(A = "i"),
                col_select = -B)
#> Warning: One or more parsing issues, call `problems()` on your data frame for details,
#> e.g.:
#>   dat <- vroom(...)
#>   problems(dat)
problems(tib2)

Created on 2025-03-17 with reprex v2.1.1

ginolhac avatar Mar 17 '25 13:03 ginolhac