-
Notifications
You must be signed in to change notification settings - Fork 6
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
Anonymous inline functions #56
Comments
I'll take a look at this! Thank you for posting. |
The challenge here is that TidierData thinks that For now, the best way to work with anonymous functions in TidierData is to use julia> df = DataFrame(ID1 = ["ID_1", "ID_23", "ID_456"])
3×1 DataFrame
Row │ ID1
│ String
─────┼────────
1 │ ID_1
2 │ ID_23
3 │ ID_456
julia> df = @mutate(df, across(ID1, s -> [split.(s, "_")[end] for s in s]))
3×2 DataFrame
Row │ ID1 ID1_function
│ String SubString…
─────┼──────────────────────
1 │ ID_1 1
2 │ ID_23 23
3 │ ID_456 456 |
Here's another approach that works: julia> df = @chain df begin
@mutate(across(ID1, s -> split.(s, "_")))
@unnest_wider(ID1_function)
end
3×3 DataFrame
Row │ ID1 ID1_function1 ID1_function2
│ String SubString… SubString…
─────┼──────────────────────────────────────
1 │ ID_1 ID 1
2 │ ID_23 ID 23
3 │ ID_456 ID 456 |
This code works at extracting the number:
But I would like to be able to do it without the helper function. However, this does not work:
The text was updated successfully, but these errors were encountered: