Skip to content

Commit

Permalink
Emit a more useful error from fortify.grouped_df when dplyr is not in…
Browse files Browse the repository at this point in the history
…stalled

Fixes tidyverse#2822
  • Loading branch information
jimhester committed Aug 10, 2018
1 parent 4d2ca99 commit ea62f7a
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 ea62f7a

Please sign in to comment.