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

separate_wider_position & names_sep #1588

Open
hanguojun007 opened this issue Jan 29, 2025 · 1 comment
Open

separate_wider_position & names_sep #1588

hanguojun007 opened this issue Jan 29, 2025 · 1 comment

Comments

@hanguojun007
Copy link

Hi ,this is my example, i think it may be wrong.
when i set names_sep = "_" and cols_remove = FALSE,the x column become x_x.

df4 <- tibble(x = c("202215TX", "202122LACC", "202325"))
df4 |>
  separate_wider_position(
    x,
    widths = c(year = 4, age = 2, state = 2),
    names_sep = "_",
    too_few = "align_start",
    too_many = "drop",
    cols_remove = FALSE
  )

A tibble: 3 × 4

x_year x_age x_state x_x

1 2022 15 TX 202215TX
2 2021 22 LA 202122LACC
3 2023 25 NA 202325

@Edgar-Zamora
Copy link

I think this might the be the expected behavior. According to the docs for the names_sep argument, it is a "composed of the input column name followed by the separator followed by the new column name". So in this instance it is x (input column) + _ (separator) + x (new column name).

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

2 participants