in_range | R Documentation |
Test wether a variable falls within a range.
in_range(x, min, max, ...)
## Default S3 method:
in_range(x, min, max, strict = FALSE, ...)
## S3 method for class 'character'
in_range(x, min, max, strict = FALSE, format = "auto", ...)
x |
A bare (unquoted) variable name. |
min |
lower bound |
max |
upper bound |
... |
arguments passed to other methods |
strict |
|
format |
|
d <- data.frame(
number = c(3,-2,6)
, time = as.Date(c("2018-02-01", "2018-03-01", "2018-04-01"))
, period = c("2020Q1", "2021Q2", "2020Q3")
)
rules <- validator(
in_range(number, min=-2, max=7, strict=TRUE)
, in_range(time, min=as.Date("2017-01-01"), max=as.Date("2018-12-31"))
, in_range(period, min="2020Q1", max="2020Q4")
)
result <- confront(d, rules)
values(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.