readr icon indicating copy to clipboard operation
readr copied to clipboard

Reconsider/remove message after `read_*()`

Open mine-cetinkaya-rundel opened this issue 1 year ago • 1 comments

The following is the current result of reading a CSV file:

library(readr)

mtcars <- read_csv(readr_example("mtcars.csv"))
#> Rows: 32 Columns: 11
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> dbl (11): mpg, cyl, disp, hp, drat, wt, qsec, vs, am, gear, carb
#> 
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Created on 2024-01-29 with reprex v2.0.2

I think the message can be entirely removed.

  • The info items can be confusing for new learners who will either learn to ignore messages (which is what experienced folks do most of the time when they see this message) or get confused about whether they must act on the suggestions or they can act on them.
  • As suggested in #1469, the reporting of the delimiter is redundant for functions like read_csv(), read_tsv(), etc.

We discussed the possibility of a package or tidyverse level strict option where the user would have to specify column types (which is preferable for production settings), but for most interactive usage the messaging is either unnecessary or confusing (particularly to new learners).

At a minimum, I'd suggest removing the info items.

mine-cetinkaya-rundel avatar Jan 29 '24 18:01 mine-cetinkaya-rundel

To further elaborate on the problems, the advice on how to use spec() is also pretty underwhelming. Because you can't just call spec(), you need to call it on the results of read_csv(), so we aren't giving a particularly useful hint and there's no obvious way to fix that.

> spec()
Error in spec() : argument "x" is missing, with no default
Run `rlang::last_trace()` to see where the error occurred.
> spec(mtcars)
cols(
  mpg = col_double(),
  cyl = col_double(),
  disp = col_double(),
  hp = col_double(),
  drat = col_double(),
  wt = col_double(),
  qsec = col_double(),
  vs = col_double(),
  am = col_double(),
  gear = col_double(),
  carb = col_double()
)

jennybc avatar Jan 29 '24 21:01 jennybc