tidyverse / readr

Read flat files (csv, tsv, fwf) into R
https://readr.tidyverse.org
Other
1.01k stars 286 forks source link

Reconsider/remove message after `read_*()` #1532

Open mine-cetinkaya-rundel opened 8 months ago

mine-cetinkaya-rundel commented 8 months ago

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.

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.

jennybc commented 8 months ago

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()
)