-
Notifications
You must be signed in to change notification settings - Fork 417
Closed
Milestone
Description
Moving from Slack.
I just used separate_wider_regex()
on a tibble created with parsermd on the section headings from a chapter from R Packages.
It turns out I needed to specify names_sep
and too_few
, but those user errors interact with each other in a way that makes it harder to figure out what's wrong.
library(tidyverse)
x <- tribble(
~ sec_h1, ~ sec_h2,
"Intro {intro}", NA,
"First cool thing {first-cool-thing}", NA,
"First cool thing {first-cool-thing}", "First cool details {first-cool-details}",
"Second cool thing", NA
)
x |>
separate_wider_regex(
everything(),
c("text" = "[^\\{]*", " [{]", label = ".*", "[}]"),
too_few = "debug"
)
#> Warning: Debug mode activated: adding variables `sec_h1_ok`, `sec_h1_matches`, and
#> `sec_h1_remainder`.
#> Warning: Debug mode activated: adding variables `sec_h2_ok`, `sec_h2_matches`, and
#> `sec_h2_remainder`.
#> Error in `unpack()`:
#> ! Names must be unique.
#> ✖ These names are duplicated:
#> * "text" at locations 1 and 7.
#> * "label" at locations 2 and 8.
#> ℹ Use argument `names_repair` to specify repair strategy.
I think I should be getting scolded first and foremost for not specifying names_sep
, which is actually required since cols = everything()
. That is the root cause of the unpack()
error but the suggested remedy is off-base.
I'd probably also be happy with some default choice of names_sep
(related #1367).
Until you get the naming stuff straightened out, you can't see the cool too_few = "debug"
diagnostics.
Metadata
Metadata
Assignees
Labels
No labels