From b4bdb31acf4bdd1b7bf57a71aeef17d85204ade1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sat, 6 May 2017 22:35:11 +0200 Subject: [PATCH 1/2] use map_xxx() --- R/tibble.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/tibble.R b/R/tibble.R index be7db35b2..17821fd3c 100644 --- a/R/tibble.R +++ b/R/tibble.R @@ -94,14 +94,14 @@ check_tibble <- function(x) { } # Types - is_1d <- vapply(x, is_1d, logical(1)) + is_1d <- map_lgl(x, is_1d) if (any(!is_1d)) { invalid_df("Each variable must be a 1d atomic vector or list", x, !is_1d) } - x[] <- lapply(x, strip_dim) + x[] <- map(x, strip_dim) - posixlt <- vapply(x, inherits, "POSIXlt", FUN.VALUE = logical(1)) + posixlt <- map_lgl(x, inherits, "POSIXlt") if (any(posixlt)) { invalid_df("Date/times must be stored as POSIXct, not POSIXlt", x, posixlt) } @@ -115,7 +115,7 @@ recycle_columns <- function(x) { } # Validate column lengths - lengths <- vapply(x, NROW, integer(1)) + lengths <- map_int(x, NROW) max <- max(lengths) bad_len <- lengths != 1L & lengths != max @@ -125,7 +125,7 @@ recycle_columns <- function(x) { short <- lengths == 1 if (max != 1L && any(short)) { - x[short] <- lapply(x[short], rep, max) + x[short] <- map(x[short], rep, max) } x From 2bd2ddad03233dcd2cad9e1798db45249a7e0066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sat, 6 May 2017 22:35:50 +0200 Subject: [PATCH 2/2] use abort() and warn() --- R/utils.r | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/utils.r b/R/utils.r index 1fb1e27f3..d0c7f3c44 100644 --- a/R/utils.r +++ b/R/utils.r @@ -39,11 +39,11 @@ safe_match <- function(x, table) { } stopc <- function(...) { - stop(..., call. = FALSE, domain = NA) + abort(paste0(...)) } warningc <- function(...) { - warning(..., call. = FALSE, domain = NA) + warn(paste0(...)) } nchar_width <- function(x) {