I want to automatically verify assumptions on columns of my tibble using assertr. The problem is that I have hundreds of columns so I can't apply them column by column. Data looks like this:
df <- tibble(
x = c(1,0,1,1,2),
y = c('A', 'B', 'C', 'D', 'A'),
z = c(1/3, 4, 5/7, 100, 3))
Then I have another tibble which describes types of columns:
df_map <- tibble(
col = c('x','y','z'),
col_type = c('POSSIBLE VALUES 0 AND 1', 'LESS THAN 1 MISSING VALUE', 'POSITIVE VALUE')
)
This can be written like:
df %>%
assert(in_set(0,1), x) %>%
assert_rows(num_row_NAs, within_bounds(0,1), y) %>%
verify(z > 0)
My question is how to apply these verifications (or any other) with this mapping so I don't need to write them for every single column.