Description Usage Arguments Details See Also Examples
Pattern predicates
1 2 3 4 5 | chk_grepl(x, pattern, ignore.case = FALSE, perl = FALSE)
chk_starts_with(x, prefix, na.rm = FALSE)
chk_ends_with(x, suffix, na.rm = FALSE)
|
x |
Object to test. |
pattern |
Regular expression. |
ignore.case |
Should pattern matching ignore case? |
perl |
Should Perl-compatible regular expressions be used? |
prefix, suffix |
String to match. |
na.rm |
Should |
To maintain consistency with grepl()
, chk_starts_with()
and
chk_ends_with()
coerce to character
before matching.
grepl()
, startsWith()
, endsWith()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ymd <- function(y, m, d) paste(y, m, d, sep = "/")
too_old <- "Not a 21st-century year"
recent_ymd <- firmly(ymd, !! too_old := chk_grepl("^20[[:digit:]]{2}$", y))
recent_ymd(2017, 01, 01)
## Not run:
recent_ymd(1999, 01, 01)
## End(Not run)
way_too_old <- "Pre-2010 year is too old"
more_recent_ymd <- firmly(ymd, !! way_too_old := chk_starts_with("201", y))
more_recent_ymd(2017, 01, 01)
## Not run:
more_recent_ymd(2001, 01, 01)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.