Skip to content

Commit

Permalink
Improve error from fortify.grouped_df when dplyr is not installed
Browse files Browse the repository at this point in the history
Fixes #2822
  • Loading branch information
jimhester committed Aug 10, 2018
1 parent 7811f04 commit c9eb593
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ggplot2 3.0.0.9000

* `fortify()` now displays a more informative error message for
`grouped_df()` objects when dplyr is not installed (@jimhester, #2822).

* All `geom_*()` now display an informative error message when required
aesthetics are missing (@dpseidel, #2637 and #2706).

Expand Down
3 changes: 3 additions & 0 deletions R/fortify.r
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ fortify.NULL <- function(model, data, ...) waiver()
fortify.function <- function(model, data, ...) model
#' @export
fortify.grouped_df <- function(model, data, ...) {
if (!requireNamespace("dplyr", quietly = TRUE)) {
stop("dplyr must be installed to work with grouped_df objects", call. = FALSE)
}
model$.group <- dplyr::group_indices(model)
model
}
Expand Down

0 comments on commit c9eb593

Please sign in to comment.