Skip to content

Commit

Permalink
reduced vcat for more flexibility in arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
pdeffebach committed Jan 2, 2019
1 parent 817d023 commit a43f53c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/groupeddataframe/grouping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,19 @@ combine(gd::GroupedDataFrame, f::Any) = combine(f, gd)
# pair syntax
function combine(gd::GroupedDataFrame, args::Union{Pair, AbstractVector{<:Pair}}...; kwargs...)

# todo: fix this bad naming
# handle pairs on their own so we can iterate
args = reduce(vcat, args)

if args isa Pair
args = [args]
end

# nams: the name of the new variable
# for the keyword arguments, this is explicitely given
nams_kw = collect(propertynames(values(kwargs)))
# the pair of input column => function
pairs_kw = collect(values(values(kwargs)))

# handle pairs on their own so we can iterate
if args isa Pair
args = [p]
end

# For the pairs, we need to auto-generate the names of the new columns here.
# i.e. :b => mean gets the name :b_mean
nams_main = [Symbol(names(gd.parent)[index(gd.parent)[first(p)]],
Expand Down

0 comments on commit a43f53c

Please sign in to comment.