tidyverse / stringr

A fresh approach to string manipulation in R

Home Page:https://stringr.tidyverse.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

str_split simplify in mutate with native pipe - potentially untidy behaviour

bfordAIMS opened this issue · comments

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
.

Maybe you want str_split_1() or str_split_i()?