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

convert option for separate_wider_* #1513

Open
paulstillman opened this issue Sep 1, 2023 · 1 comment
Open

convert option for separate_wider_* #1513

paulstillman opened this issue Sep 1, 2023 · 1 comment
Labels
feature a feature request or enhancement strings 🎻

Comments

@paulstillman
Copy link

One of the most useful functions of the now superseded separate was the convert = TRUE option that would convert the resulting new columns into, for instance, numeric vectors. So the following:

df <- tibble(a = '1,2,3')
df |> 
  separate(a, into = c('num1', 'num2', 'num3'), sep = ',', convert = TRUE)

outputs as numeric columns:

   num1  num2  num3
  <int> <int> <int>
1     1     2     3

If we do the equivalent separate_wider_delim call:

df |> 
  separate_wider_delim(a, names = c('num1', 'num2', 'num3'), delim = ',')

the output is all character outputs:

  num1  num2  num3 
  <chr> <chr> <chr>
1 1     2     3    

Would it be possible to re-introduce the convert option to separate_wider_delim?

@DavisVaughan
Copy link
Member

DavisVaughan commented Sep 6, 2023

I think it would be reasonable to introduce names_transform to the separate_wider_*() family, like we have for pivot_longer() (it is a more precise version of convert)

@DavisVaughan DavisVaughan added feature a feature request or enhancement pivoting ♻️ pivot rectangular data to different "shapes" strings 🎻 and removed pivoting ♻️ pivot rectangular data to different "shapes" labels Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement strings 🎻
Projects
None yet
Development

No branches or pull requests

2 participants