Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In separate_wider_delim(), could merge have an option for too_many = "merge_end" #1551

Open
olivroy opened this issue May 1, 2024 · 0 comments

Comments

@olivroy
Copy link
Contributor

olivroy commented May 1, 2024

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

Created on 2024-05-01 with reprex v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant