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
{{ message }}
In separate_wider_delim(), allow for specifying the direction to split by delim in #1551
There is no way with separate wider delim to use the spaces from the end. The docs say to use separate_wider_regex(), but I wonder if the delim function could add an option.
Of course, a workaround is to construct a more complex regex and to use separate_wider_regex(), but that could become clunky?
dplyr::tibble(
col= c(
"A label with space 1.0 2.31",
"Non-space label 1.22 3.21"
)
) |>tidyr::separate_wider_delim(
cols=col,
delim="",
names= c("label", "n1", "n2"),
too_many="merge"
)
#> # A tibble: 2 × 3#> label n1 n2 #> <chr> <chr> <chr> #> 1 A label with space 1.0 2.31#> 2 Non-space label 1.22 3.21
I don't think it would go in too_many though, I think it would be a new argument to separate_wider_delim() like direction = c("forward", "backward") that specifies the direction to split by the delim in
Need to keep in mind that delim is allowed to be stringr::regex() and friends, which may complicate things.
changed the title [-]In `separate_wider_delim()`, could `merge` have an option for `too_many = "merge_end"`[/-][+]In `separate_wider_delim()`, allow for specifying the direction to split by `delim` in[/+]on Oct 24, 2024
I don't think it would go in too_many though, I think it would be a new argument to separate_wider_delim() like direction = c("forward", "backward") that specifies the direction to split by the delim in
Although, it would be natural to have too_many = c("error", "debug", "drop", "merge_start", "merge_end"), as it would be similar too_few = c("error", "debug", "align_start", "align_end").
Activity
DavisVaughan commentedon Oct 24, 2024
Seems like a reasonable feature request, another idea for now is to double reverse the string
Created on 2024-10-24 with reprex v2.1.1
DavisVaughan commentedon Oct 24, 2024
I don't think it would go in
too_manythough, I think it would be a new argument toseparate_wider_delim()likedirection = c("forward", "backward")that specifies the direction to split by thedeliminNeed to keep in mind that
delimis allowed to bestringr::regex()and friends, which may complicate things.[-]In `separate_wider_delim()`, could `merge` have an option for `too_many = "merge_end"`[/-][+]In `separate_wider_delim()`, allow for specifying the direction to split by `delim` in[/+]DanChaltiel commentedon Feb 7, 2025
Although, it would be natural to have
too_many = c("error", "debug", "drop", "merge_start", "merge_end"), as it would be similartoo_few = c("error", "debug", "align_start", "align_end").