-
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
Allow group
to take in an AbstractVector
of groups?
#30
Comments
Yes I think this is a good idea, though we need to be careful that dispatch works out. I also thought we might have had something like this? (Perhaps it’s the internal function). |
I don't feel that strongly about it. It was just a surprising omission because without this there is no exact equivelent to a |
Hi @pdeffebach, I finally got some time at the computer and see we already have this behavior: julia> g = [1, 1, 2, 2]
4-element Array{Int64,1}:
1
1
2
2
julia> x = [5, 6, 7, 8]
4-element Array{Int64,1}:
5
6
7
8
julia> group(g, x)
2-element Dictionaries.Dictionary{Int64,Array{Int64,1}}
1 │ [5, 6]
2 │ [7, 8] Is this what you were expecting? |
Regarding R's |
Thanks for this. One final question, is there a version of this for I've been doing data cleaning at the repl and not having to write out a full |
I'm not sure what you are seeking? Is it this? julia> g = [1, 1, 2, 2]
4-element Array{Int64,1}:
1
1
2
2
julia> x = [5, 6, 7, 8]
4-element Array{Int64,1}:
5
6
7
8
julia> groups = group(g, x)
2-element Dictionaries.Dictionary{Int64,Array{Int64,1}}
1 │ [5, 6]
2 │ [7, 8]
julia> map(x -> groups[x], g)
4-element Array{Array{Int64,1},1}:
[5, 6]
[5, 6]
[7, 8]
[7, 8] |
Sorry for forgetting about this thread. I think the infrastructure has almost what I want, but I would like this to be in one function (The package is called SplitApplyCombine after all)
This would be nice to have. For reference, my motivation is for supporting grouped operations inside DataFramesMeta's An added bonus on the above would be to allow multiple arguments, i.e. |
Out of general principles, it seems more optimal to have fewer general functions that easily compose ( map(mean, group([1, 1, 2, 2], [5, 6, 7, 8])) already looks very short, intuitive and clear - when one knowns what |
Something like
The text was updated successfully, but these errors were encountered: