Skip to content
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

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

Open
ChristopherEeles opened this issue Nov 28, 2022 · 0 comments
Open

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

ChristopherEeles opened this issue Nov 28, 2022 · 0 comments

Comments

@ChristopherEeles
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant