Skip to content

Return messages for each vetting condition failed #85

@franknarf1

Description

@franknarf1

I am vetting a vector and am interested in seeing a "full report" when it fails:

library(vetr)
library(data.table)

date8_toIDate = function(x) as.IDate(as.character(x), format = "%Y%m%d")

DATE8 = vet_token( INT && !is.na(date8_toIDate(.)) )

x = c(20010102L, 20010101L, 20010100L)
y = replace(x, 2, NA)

vet(DATE8, x)
# [1] "`!is.na(date8_toIDate(x))` is not all TRUE (contains non-TRUE values)"
vet(DATE8, y)
# [1] "`y` should not contain NAs, but does"

So the format is an 8-digit number representing a date. For the vector y, I want to see both that it has NAs and also that its non-NAs fail my conversion test, like...

multivet(DATE8, y)
# [1] "`y` should not contain NAs, but does"    
# [1] "`!is.na(date8_toIDate(y))` is not all TRUE (contains non-TRUE values)"

Background. You could argue that I can fix y's NAs; rerun; and then catch the other condition. The problem is that I am not passing these interactively. Instead, someone else has a non-R script for pulling from various databases and manipulating data in an attempt to meet my documented vetting conditions. Running their input-generating program is time-consuming, so I'd like them to get a full report of input problems whenever any are present so they can fix them all at once.

This may be outside of what you had in mind for the package, but it looks somewhat close to the already-included functionality.

EDIT: Thinking about this more, the behavior I'm asking for may be ill defined. I guess there would need to be a rule that a particular sequence of conditions in the token is traversed. So in AA && BB && CC, if AA fails, it will only examine BB on those where AA passed; and where BB fails on some, again it would test CC only where it passed.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions