Skip to content

print_misspelled_values() fails with multiple row indices #281

Description

@Degoot-AM

print_misspelled_values() incorrectly uses [[ to subset a data column with the row indices returned by detect_misspelled_options2().

undefined_opts <- data[[option]][[misspelled_options[[option]]]]

Proposed fix

Replace [[ with [:

print_misspelled_values <- function(data, misspelled_options) {
  for (option in names(misspelled_options)) {
    undefined_opts <- unique(data[[option]][misspelled_options[[option]]])

    cli::cli_alert_warning(
      tr_(
        "Cannot replace {.val {toString(undefined_opts)}} present in column {.field {option}} but not defined in the dictionary."
      )
    )
  }

  invisible(NULL)
}

Using [ supports a vector of row indices, while unique() avoids printing the same undefined value repeatedly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions