Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Check for correct input in arrange/mutate/summarise

  • Loading branch information...
commit 07680cc444befdaba8e00e94bd03ad8497dfcf7a 1 parent cc34a2e
@hadley authored
View
2  R/helper-arrange.r
@@ -23,6 +23,8 @@
#' # Sort with displacement in descending order
#' arrange(myCars, cyl, desc(disp))
arrange <- function(df, ...) {
+ stopifnot(is.data.frame(df))
+
ord <- eval(substitute(order(...)), df, parent.frame())
if(length(ord) != nrow(df)) {
stop("Length of ordering vectors don't match data frame size",
View
2  R/helper-mutate.r
@@ -26,6 +26,8 @@
#' system.time(transform(baseball, avg_ab = ab / g))
#' system.time(mutate(baseball, avg_ab = ab / g))
mutate <- function(.data, ...) {
+ stopifnot(is.data.frame(.data) || is.list(.data) || is.environment(.data))
+
cols <- as.list(substitute(list(...))[-1])
cols <- cols[names(cols) != ""] # Silently drop unnamed columns
View
2  R/helper-summarise.r
@@ -21,6 +21,8 @@
#' duration = max(year) - min(year),
#' nteams = length(unique(team)))
summarise <- function(.data, ...) {
+ stopifnot(is.data.frame(.data) || is.list(.data) || is.environment(.data))
+
cols <- as.list(substitute(list(...))[-1])
# ... not a named list, figure out names by deparsing call
Please sign in to comment.
Something went wrong with that request. Please try again.