You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From my recent issue (#85): I'm testing if a numeric input can be interpreted as an 8-digit date:
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, 20010100L)
vet(DATE8, x)
# "`!is.na(date8_toIDate(x))` is not all TRUE (contains non-TRUE values)"
It would be nice if the token was somehow magically parsed so that the message was instead...
magicvet(DATE8, x)
# [1] "`date8_toIDate(x)` should not contain NAs, but does"
Alternately, maybe there could be syntax so I can write my token as..
DATE8 = vet_token( INT && NO.NA(date8_toIDate(.)) )
with the messaging behavior mentioned above.
The text was updated successfully, but these errors were encountered:
franknarf1
changed the title
magic so vet(!is.na(f(.)), x) reports "f(x)" should not contain NAs, but does
magic so vet(!is.na(f(.)), x) reports "f(x) should not contain NAs, but does"
Nov 23, 2017
A possible solution (and unfortunately of the manual and not magic variety):
DATE8.SUB <- vet_token(
!anyNA(date8_toIDate(.)),
"date8_toIdate(%s) should not contain NAs, but does"
)
vet(DATE8.SUB && INT, y)
## [1] "date8_toIdate(`y` ) should not contain NAs, but does"
There is a string formatting issue with an extra space getting injected that I'll have to fix.
Note that you only need to use vet_token if you want to supply a custom message was we do here. In normal use where vet writes its own messages you can just use quote.
From my recent issue (#85): I'm testing if a numeric input can be interpreted as an 8-digit date:
It would be nice if the token was somehow magically parsed so that the message was instead...
Alternately, maybe there could be syntax so I can write my token as..
with the messaging behavior mentioned above.
The text was updated successfully, but these errors were encountered: