tidyverse / purrr

@@ -227,9 +227,7 @@
Loading
227 227
#'   Only applies to `_dfr` variant.
228 228
#' @export
229 229
map_dfr <- function(.x, .f, ..., .id = NULL) {
230 -
  if (!is_installed("dplyr")) {
231 -
    abort("`map_df()` requires dplyr")
232 -
  }
230 +
  check_installed("dplyr", "for `map_dfr()`.")
233 231
234 232
  .f <- as_mapper(.f, ...)
235 233
  res <- map(.x, .f, ...)
@@ -244,9 +242,7 @@
Loading
244 242
#' @rdname map
245 243
#' @export
246 244
map_dfc <- function(.x, .f, ...) {
247 -
  if (!is_installed("dplyr")) {
248 -
    abort("`map_dfc()` requires dplyr")
249 -
  }
245 +
  check_installed("dplyr", "for `map_dfc()`.")
250 246
251 247
  .f <- as_mapper(.f, ...)
252 248
  res <- map(.x, .f, ...)

@@ -10,28 +10,16 @@
Loading
10 10
11 11
maybe_as_data_frame <- function(out, x) {
12 12
  if (is.data.frame(x)) {
13 -
    check_tibble()
13 +
    check_installed("tibble")
14 14
    tibble::as_tibble(out)
15 15
  } else {
16 16
    out
17 17
  }
18 18
}
19 19
20 -
check_tibble <- function() {
21 -
  if (!is_installed("tibble")) {
22 -
    abort("The tibble package must be installed")
23 -
  }
24 -
}
25 -
26 -
check_tidyselect <- function(){
27 -
  if (!is_installed("tidyselect")) {
28 -
    abort("Using tidyselect in `map_at()` requires tidyselect")
29 -
  }
30 -
}
31 -
32 20
at_selection <- function(nm, .at){
33 -
  if (is_quosures(.at)){
34 -
    check_tidyselect()
21 +
  if (is_quosures(.at)) {
22 +
    check_installed("tidyselect", "for using tidyselect in `map_at()`.")
35 23
    .at <- tidyselect::vars_select(.vars = nm, !!!.at)
36 24
  }
37 25
  .at

@@ -63,9 +63,7 @@
Loading
63 63
#' @export
64 64
#' @rdname flatten
65 65
flatten_dfr <- function(.x, .id = NULL) {
66 -
  if (!is_installed("dplyr")) {
67 -
    abort("`flatten_dfr()` requires dplyr")
68 -
  }
66 +
  check_installed("dplyr", "for `flatten_dfr()`.")
69 67
70 68
  res <- .Call(flatten_impl, .x)
71 69
  dplyr::bind_rows(res, .id = .id)
@@ -74,9 +72,7 @@
Loading
74 72
#' @export
75 73
#' @rdname flatten
76 74
flatten_dfc <- function(.x) {
77 -
  if (!is_installed("dplyr")) {
78 -
    abort("`flatten_dfc()` requires dplyr")
79 -
  }
75 +
  check_installed("dplyr", "for `flatten_dfc()`.")
80 76
81 77
  res <- .Call(flatten_impl, .x)
82 78
  dplyr::bind_cols(res)

@@ -198,7 +198,7 @@
Loading
198 198
    "tidyr::expand_grid()",
199 199
    details = c(i = "See <https://github.com/tidyverse/purrr/issues/768>.")
200 200
  )
201 -
  check_tibble()
201 +
  check_installed("tibble")
202 202
  cross(.l, .filter = .filter) %>%
203 203
    transpose() %>%
204 204
    simplify_all() %>%

@@ -136,20 +136,17 @@
Loading
136 136
#' @rdname map2
137 137
#' @export
138 138
map2_dfr <- function(.x, .y, .f, ..., .id = NULL) {
139 -
  if (!is_installed("dplyr")) {
140 -
    abort("`map2_dfr()` requires dplyr")
141 -
  }
139 +
  check_installed("dplyr", "for `map2_dfr()`.")
142 140
143 141
  .f <- as_mapper(.f, ...)
144 142
  res <- map2(.x, .y, .f, ...)
145 143
  dplyr::bind_rows(res, .id = .id)
146 144
}
145 +
147 146
#' @rdname map2
148 147
#' @export
149 148
map2_dfc <- function(.x, .y, .f, ...) {
150 -
  if (!is_installed("dplyr")) {
151 -
    abort("`map2_dfc()` requires dplyr")
152 -
  }
149 +
  check_installed("dplyr", "for `map2_dfc()`.")
153 150
154 151
  .f <- as_mapper(.f, ...)
155 152
  res <- map2(.x, .y, .f, ...)
@@ -231,9 +228,7 @@
Loading
231 228
#' @rdname map2
232 229
#' @export
233 230
pmap_dfr <- function(.l, .f, ..., .id = NULL) {
234 -
  if (!is_installed("dplyr")) {
235 -
    abort("`pmap_dfr()` requires dplyr")
236 -
  }
231 +
  check_installed("dplyr", "for `pmap_dfr()`.")
237 232
238 233
  .f <- as_mapper(.f, ...)
239 234
  res <- pmap(.l, .f, ...)
@@ -243,9 +238,7 @@
Loading
243 238
#' @rdname map2
244 239
#' @export
245 240
pmap_dfc <- function(.l, .f, ...) {
246 -
  if (!is_installed("dplyr")) {
247 -
    abort("`pmap_dfc()` requires dplyr")
248 -
  }
241 +
  check_installed("dplyr", "for `pmap_dfc()`.")
249 242
250 243
  .f <- as_mapper(.f, ...)
251 244
  res <- pmap(.l, .f, ...)
Files Coverage
R 92.27%
src 89.84%
Project Totals (46 files) 91.39%
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: auto
8
        threshold: 1%
9
        informational: true
10
    patch:
11
      default:
12
        target: auto
13
        threshold: 1%
14
        informational: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading