problems | R Documentation |
problems()
is a companion helper function to create_iso8601()
. It
retrieves ISO 8601 parsing problems from an object of class iso8601, which is
create_iso8601()
's return value and that might contain a problems
attribute in case of parsing failures. problems()
is a helper function that
provides easy access to these parsing problems.
problems(x = .Last.value)
x |
An object of class iso8601, as typically obtained from a call to
|
If there are no parsing problems in x
, then the returned value is
NULL
; otherwise, a tibble of parsing failures
is returned. Each row corresponds to a parsing problem. There will be a
first column named ..i
indicating the position(s) in the inputs to the
create_iso8601()
call that resulted in failures; remaining columns
correspond to the original input values passed on to create_iso8601()
,
with columns being automatically named ..var1
, ..var2
, and so on, if
the inputs to create_iso8601()
were unnamed, otherwise, the original
variable names are used instead.
dates <-
c(
"2020-01-01",
"2020-02-11",
"2020-01-06",
"2020-0921",
"2020/10/30",
"2020-12-05",
"20231225"
)
# By inspecting the problematic dates it can be understood that
# the `.format` parameter needs to updated to include other variations.
iso8601_dttm <- create_iso8601(dates, .format = "y-m-d")
problems(iso8601_dttm)
# Including more parsing formats addresses the previous problems
formats <- c("y-m-d", "y-md", "y/m/d", "ymd")
iso8601_dttm2 <- create_iso8601(dates, .format = list(formats))
# So now `problems()` returns `NULL` because there are no more parsing issues.
problems(iso8601_dttm2)
# If you pass named arguments when calling `create_iso8601()` then they will
# be used to create the problems object.
iso8601_dttm3 <- create_iso8601(date = dates, .format = "y-m-d")
problems(iso8601_dttm3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.