-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: Implement separate() #107
base: master
Are you sure you want to change the base?
feat: Implement separate() #107
Conversation
Thanks, this looks nice. I'm going away until the end of the week, starting from tonight. I'll try to look properly when I'm back. |
1f2d19c
to
fec063c
Compare
I took a look into some of this re n_max <- length(into)
m <- gregexpr(sep, as.character(data[[col]]), perl = TRUE)
if (n_max > 0) {
m <- lapply(m, function(x) {
i <- seq_along(x) < n_max
structure(
x[i],
match.length = attr(x, "match.length")[i],
index.type = attr(x, "index.type"),
useBytes = attr(x, "useBytes")
)
})
}
regmatches(as.character(data[[col]]), m, invert = TRUE) The problem is this doesn't get rid of "extra" information. df <- data.frame(x = c("x", "x y", "x y z", NA))
# a b
# 1 x <NA>
# 2 x y
# 3 x y z
# 4 <NA> <NA> Row 3 should be |
Here is an example of what
|
Passing thought: might be worth implementing |
I saw those. I may give them a miss. At some point I need to make a cut off and dplyr and tidyr 1.0.0 make sense to me. |
I understand that you can't cover all new things in |
Ah I see what you mean. Yeah that seems like a good point, actually. |
This PR implements
separate()
to split a column into several ones, either based on a regex or on location.@nathaneastwood this PR is not complete, I put it as a draft here so that it is saved somewhere and that you can help with the TODO list if you have some time.
TODO:
extra = "merge"
(1 test failing so far)fill
(the way this argument works is not very clear to me)Some examples:
Created on 2022-08-03 by the reprex package (v2.0.1)