Skip to content

Commit c9eb593

Browse files
committed
Improve error from fortify.grouped_df when dplyr is not installed
Fixes #2822
1 parent 7811f04 commit c9eb593

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ggplot2 3.0.0.9000
22

3+
* `fortify()` now displays a more informative error message for
4+
`grouped_df()` objects when dplyr is not installed (@jimhester, #2822).
5+
36
* All `geom_*()` now display an informative error message when required
47
aesthetics are missing (@dpseidel, #2637 and #2706).
58

R/fortify.r

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ fortify.NULL <- function(model, data, ...) waiver()
2828
fortify.function <- function(model, data, ...) model
2929
#' @export
3030
fortify.grouped_df <- function(model, data, ...) {
31+
if (!requireNamespace("dplyr", quietly = TRUE)) {
32+
stop("dplyr must be installed to work with grouped_df objects", call. = FALSE)
33+
}
3134
model$.group <- dplyr::group_indices(model)
3235
model
3336
}

0 commit comments

Comments
 (0)