Skip to content

When multiple comma-separated columns are selected in assert_rows, it gives an error when building the violations data.frame #83

@theunis

Description

@theunis

Example:

mtcars[2:4, "mpg"] <- NA
mtcars[2:4, "am"] <- NA
mtcars %>% 
  assert_rows(num_row_NAs, within_bounds(0,1), mpg, am)

gives

Error in data.frame(verb = verb, redux_fn = name.of.rowredux.fn, predicate = name.of.predicate,  : 
  arguments imply differing number of rows: 1, 2, 3

This error resides in the function make.assertr.assert_rows.error. Right here:

error_df <- data.frame(verb = verb, redux_fn = name.of.rowredux.fn, 
    predicate = name.of.predicate, column = column, index = loc.violations, 
    value = offending.elements)

The columns need to be collated in some way so that it becomes a vector of length 1, before it is inserted into the error_df data.frame.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions