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

str_split simplify in mutate with native pipe - potentially untidy behaviour #522

Closed
half-normal opened this issue Aug 11, 2023 · 1 comment

Comments

@half-normal
Copy link

In the below example we see that using str_split(..., simplify = TRUE) |> _[2] within a mutate call requires a rowwise statement to produce the expected output. I assume this is because simplify produces a character matrix rather than vector of strings.

Is this expected behaviour? If so it might be useful to have an unlist argument analogue of simplify which produces a vector of strings rather than a character matrix. I.e. the two would be equivalent: str_split(..., unlist = TRUE) & str_split(...) |> unlist() . As I'm typing this I am realising that this is the latter is actually more succinct 😅, so feel free to close this if this is expected behaviour
tempsnip
.

@hadley
Copy link
Member

hadley commented Oct 31, 2023

Maybe you want str_split_1() or str_split_i()?

@hadley hadley closed this as completed Oct 31, 2023
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