Skip to content

Proposal for repair = "unique_quiet" and repair = "universal_quiet" #1629

@jennybc

Description

@jennybc

I'd like to propose the addition of 2 name repair strings to the standard list of vec_as_names():

vec_as_names(
  ...,
  repair = c("minimal", "unique", "universal", "check_unique"),
  quiet = FALSE,
  ...
)

I'm proposing we add:

  • unique_quiet
  • universal_quiet

which would have the effect of requesting a specific level of name repair AND setting quiet = TRUE.

I know this might sound sort of gross, but hear me out 😅 The existing check_unique is already a mix of a repair strategy and how to report on repair.

I'm writing this as the maintainer of readr, vroom, readxl, and googlesheets4, all of which do name repair, with various degrees of historical baggage, but all of which do now expose a name_repair argument. Some of these packages call vctrs::vec_as_names() directly (e.g. vroom), but others do not (readxl and googlesheets4 currently access name repair via tibble).

The ability to suppress name repair messages is a common and understandable feature request from users.

These feel like my current options for addressing this:

  • Documentation: Show user how to write and use a custom name repair function that does not message.

    quiet_repair <- function(x) {
      vctrs::vec_as_names(x, repair = "unique", quiet = TRUE)
    }
    
    read_csv(I("x,x\n1,2\n3,4"), name_repair = quiet_repair)
  • Documentation: Show user how to use the rlib_name_repair_verbosity global option to suppress name repair messaging.

    withr::with_options(
      list(rlib_name_repair_verbosity = "quiet"),
      read_csv(I("x,x\n1,2\n3,4"))
    )
  • Feature: Actually change the signature of all relevant user-facing functions in readr, vroom, readxl, and googlesheets4 to expose a new, 2nd argument re: name repair, that controls verbosity. One example:

    read_excel <- function(...
      .name_repair = "unique",            # <-- this is already there
      .name_repair_verbosity = "verbose"  # <-- this would be new
    )
  • Feature: I could implement my proposal in each of these packages, by intercepting name_repair and, if I see minimal_quiet or universal_quiet, use whatever means I have available to make it so (implementation would differ across the packages).

I don't love any of these options. To quote @DavisVaughan:

I do want to make it somewhat hard to silence [name repair messages], but right now I think it is a little too hard

The first 2 solutions (documentation, user does extra work) feel too hard on the user.

The third solution (new argument everywhere) feels like a lot of work/change for such a small behavioural tweak.

The fourth solution (special handling for the new strings in certain packages) feels like it breaks a tidyverse rule re: consistency.

I think name_repair = "unique_quiet" and name_repair = "universal_quiet" could be really handy for giving users more control with the single name_repair argument commonly seen in user-facing functions. To be clear, I think we should never default to these.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions