Learn R Programming

ruler (version 0.1.3)

ruler-report: Tidy data validation report

Description

A tibble representing the data validation result of certain data units in tidy way:

  • pack <chr> : Name of rule pack from column 'name' of corresponding packs_info object.

  • rule <chr> : Name of the rule defined in rule pack.

  • var <chr> : Name of the variable which validation result is reported. Value '.all' is reserved and interpreted as 'all columns as a whole'. Note that var doesn't always represent the actual column in data frame (see group packs).

  • id <int> : Index of the row in tested data frame which validation result is reported. Value 0 is reserved and interpreted as 'all rows as a whole'.

  • value <lgl> : Whether the described data unit obeys the rule.

Usage

is_report(.x, .skip_class = FALSE)

get_report(.object)

Arguments

.x

Object to test.

.skip_class

Whether to skip checking inheritance from ruler_report.

.object

Object to get report value from exposure attribute.

Value

get_report() returns report element of object if it is exposure and of its 'exposure' attribute otherwise.

Details

There are four basic combinations of var and id values which define five basic data units:

  • var == '.all' and id == 0: Data as a whole.

  • var != '.all' and id == 0: Group (var shouldn't be an actual column name) or column (var should be an actual column name) as a whole.

  • var == '.all' and id != 0: Row as a whole.

  • var != '.all' and id != 0: Described cell.

Examples

Run this code
# NOT RUN {
my_row_packs <- row_packs(
  row_mean_props = . %>% dplyr::transmute(row_mean = rowMeans(.)) %>%
    dplyr::transmute(
      row_mean_low = row_mean > 20,
      row_mean_high = row_mean < 60
    ),
  row_outlier = . %>% dplyr::transmute(row_sum = rowSums(.)) %>%
    dplyr::transmute(
      not_row_outlier = abs(row_sum - mean(row_sum)) / sd(row_sum) < 1.5
    )
)
my_data_packs <- data_packs(
  data_dims = . %>% dplyr::summarise(nrow = nrow(.) == 32,
                                     ncol = ncol(.) == 5)
)

mtcars_exposed <- mtcars %>%
  expose(my_data_packs, .remove_obeyers = FALSE) %>%
  expose(my_row_packs)

mtcars_exposed %>% get_report()

mtcars_exposed %>% get_report() %>% is_report()

# }

Run the code above in your browser using DataLab