diff --git a/R/helper-summarise.r b/R/helper-summarise.r index f3c2eb04..476c9dfc 100644 --- a/R/helper-summarise.r +++ b/R/helper-summarise.r @@ -18,8 +18,8 @@ #' duration = max(year) - min(year), #' nteams = length(unique(team))) summarise <- function(.data, ...) { - cols <- eval(substitute(list(...)), .data, parent.frame()) - + cols <- as.list(substitute(list(...))[-1]) + # ... not a named list, figure out names by deparsing call if(is.null(names(cols))) { missing_names <- rep(TRUE, length(cols)) @@ -30,7 +30,10 @@ summarise <- function(.data, ...) { names <- unname(unlist(lapply(match.call(expand = FALSE)$`...`, deparse))) names(cols)[missing_names] <- names[missing_names] } - - quickdf(cols) + .data <- as.list(.data) + for (col in names(cols)) { + .data[[col]] <- eval(cols[[col]], .data, parent.frame()) + } + quickdf(.data[names(cols)]) } summarize <- summarise