Skip to content

Commit 1873469

Browse files
authored
Merge pull request #31 from tidyverse/master
Sync Fork from Upstream Repo
2 parents c319c2c + 199be05 commit 1873469

File tree

11 files changed

+16
-30
lines changed

11 files changed

+16
-30
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Imports:
3535
isoband,
3636
MASS,
3737
mgcv,
38-
rlang (>= 0.3.0),
38+
rlang (>= 0.4.10),
3939
scales (>= 0.5.0),
4040
stats,
4141
tibble,

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525
* ggplot2 now requires R >= 3.3 (#4247).
2626

27+
* ggplot2 now uses `rlang::check_installed()` to check if a suggested package is
28+
installed, which will offer to install the package before continuing (#4375,
29+
@malcolmbarrett)
30+
2731
# ggplot2 3.3.3
2832
This is a small patch release mainly intended to address changes in R and CRAN.
2933
It further changes the licensing model of ggplot2 to an MIT license.

R/coord-map.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ CoordMap <- ggproto("CoordMap", Coord,
318318

319319

320320
mproject <- function(coord, x, y, orientation) {
321+
check_installed("mapproj", reason = "for `coord_map()`")
321322
suppressWarnings(mapproj::mapproject(x, y,
322323
projection = coord$projection,
323324
parameters = coord$params,

R/coord-sf.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
6262
return(layer_data)
6363
}
6464

65-
sf::st_transform(layer_data, params$crs)
65+
idx <- vapply(layer_data, inherits, what = "sfc", FUN.VALUE = logical(1L))
66+
layer_data[idx] <- lapply(layer_data[idx], sf::st_transform, crs = params$crs)
67+
layer_data
6668
})
6769
},
6870

R/fortify-map.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fortify.map <- function(model, data, ...) {
7575
#' coord_map("albers", lat0 = 45.5, lat1 = 29.5)
7676
#' }
7777
map_data <- function(map, region = ".", exact = FALSE, ...) {
78-
try_require("maps", "map_data")
78+
check_installed("maps", reason = "for `map_data()`")
7979
map_obj <- maps::map(map, region, exact = exact, plot = FALSE, fill = TRUE, ...)
8080
fortify(map_obj)
8181
}

R/fortify.r

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ fortify.data.frame <- function(model, data, ...) model
1717
fortify.tbl_df <- function(model, data, ...) model
1818
#' @export
1919
fortify.tbl <- function(model, data, ...) {
20-
if (!requireNamespace("dplyr", quietly = TRUE)) {
21-
abort("dplyr must be installed to work with tbl objects")
22-
}
20+
check_installed("dplyr", reason = "to work with `tbl` objects")
2321
dplyr::collect(model)
2422
}
2523
#' @export
@@ -31,9 +29,7 @@ fortify.function <- function(model, data, ...) model
3129
fortify.formula <- function(model, data, ...) as_function(model)
3230
#' @export
3331
fortify.grouped_df <- function(model, data, ...) {
34-
if (!requireNamespace("dplyr", quietly = TRUE)) {
35-
abort("dplyr must be installed to work with grouped_df objects")
36-
}
32+
check_installed("dplyr", reason = "to work with `grouped_df` objects")
3733
model$.group <- dplyr::group_indices(model)
3834
model
3935
}

R/stat-binhex.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ StatBinhex <- ggproto("StatBinhex", Stat,
4949

5050
compute_group = function(data, scales, binwidth = NULL, bins = 30,
5151
na.rm = FALSE) {
52-
try_require("hexbin", "stat_binhex")
52+
check_installed("hexbin", reason = "for `stat_binhex()`")
5353

5454
binwidth <- binwidth %||% hex_binwidth(bins, scales)
5555
wt <- data$weight %||% rep(1L, nrow(data))

R/stat-quantile.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ StatQuantile <- ggproto("StatQuantile", Stat,
5050
compute_group = function(data, scales, quantiles = c(0.25, 0.5, 0.75),
5151
formula = NULL, xseq = NULL, method = "rq",
5252
method.args = list(), lambda = 1, na.rm = FALSE) {
53-
try_require("quantreg", "stat_quantile")
53+
check_installed("quantreg", reason = "for `stat_quantile()`")
5454

5555
if (is.null(formula)) {
5656
if (method == "rqss") {

R/stat-summary-hex.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ StatSummaryHex <- ggproto("StatSummaryHex", Stat,
4343

4444
compute_group = function(data, scales, binwidth = NULL, bins = 30, drop = TRUE,
4545
fun = "mean", fun.args = list()) {
46-
try_require("hexbin", "stat_summary_hex")
46+
check_installed("hexbin", reason = "for `stat_summary_hex()`")
4747

4848
binwidth <- binwidth %||% hex_binwidth(bins, scales)
4949
fun <- as_function(fun)

R/stat-summary.r

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,7 @@ NULL
245245
wrap_hmisc <- function(fun) {
246246

247247
function(x, ...) {
248-
if (!requireNamespace("Hmisc", quietly = TRUE))
249-
abort("Hmisc package required for this function")
248+
check_installed("Hmisc")
250249

251250
fun <- getExportedValue("Hmisc", fun)
252251
result <- do.call(fun, list(x = quote(x), ...))

0 commit comments

Comments
 (0)