Skip to content

Commit 2cff9c2

Browse files
committed
Only use dplyr conditionally
Needed for CRAN submission
1 parent 4caac5f commit 2cff9c2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ S3method(fortify,sfc)
4242
S3method(fortify,sfg)
4343
S3method(fortify,summary.glht)
4444
S3method(fortify,tbl)
45+
S3method(fortify,tbl_df)
4546
S3method(ggplot,"function")
4647
S3method(ggplot,default)
4748
S3method(ggplot_add,"NULL")

R/fortify.r

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ fortify <- function(model, data, ...) UseMethod("fortify")
1414
#' @export
1515
fortify.data.frame <- function(model, data, ...) model
1616
#' @export
17-
fortify.tbl <- function(model, data, ...) dplyr::collect(model)
17+
fortify.tbl_df <- function(model, data, ...) model
18+
#' @export
19+
fortify.tbl <- function(model, data, ...) {
20+
if (!requireNamespace("dplyr", quietly = TRUE)) {
21+
stop("dplyr must be installed to work with tbl objects", call. = FALSE)
22+
}
23+
dplyr::collect(model)
24+
}
1825
#' @export
1926
fortify.NULL <- function(model, data, ...) waiver()
2027
#' @export

0 commit comments

Comments
 (0)