Skip to content

Handle trailing commas via ... in aggregate2 method #166

@ChristopherEeles

Description

@ChristopherEeles

Found this bug today but haven't figured out a fix yet.

When calling the aggregate2 function with a trailing comma in the function arguments the call that is parsed in:

# -- capture dots as a call and parse dot names, adding default names if
# --   they are missing
agg_call <- if (enlist) substitute(list(...)) else substitute(...)

When enlist=TRUE results in a call where the last item is a missing argument. However, there is no class or type indications that allow this to be easily caught. As a result when there is a trailing comma in the call the error ends up appearing when trying to use the dot_call variable:

for (i in which(dot_names == "")) {
    dot_call <- agg_call[[i + 1]]
    # assumes the first argument in a function call is always the column name!
    dot_names[i] <- paste0(dot_call[1:max(2, length(dot_call))], collapse="_")
}

Maybe we can at least handle this error in a try block or something? Not a priority right now but its obfuscated enough that I felt I should document it.

Chris

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions