Skip to content

Commit

Permalink
Implement tidyeval for benchplot()(#2816)
Browse files Browse the repository at this point in the history
Closes #2699
  • Loading branch information
dpseidel authored Aug 10, 2018
1 parent c9eb593 commit 5f868c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ggplot2 3.0.0.9000

* `benchplot()` now uses tidy evaluation (@dpseidel, #2699).

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

Expand Down
9 changes: 7 additions & 2 deletions R/bench.r
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
#' @examples
#' benchplot(ggplot(mtcars, aes(mpg, wt)) + geom_point())
#' benchplot(ggplot(mtcars, aes(mpg, wt)) + geom_point() + facet_grid(. ~ cyl))
benchplot <- function(x) {
#'
#' # With tidy eval:
#' p <- expr(ggplot(mtcars, aes(mpg, wt)) + geom_point())
#' benchplot(!!p)

construct <- system.time(force(x))
benchplot <- function(x) {
x <- enquo(x)
construct <- system.time(x <- rlang::eval_tidy(x))
stopifnot(inherits(x, "ggplot"))

build <- system.time(data <- ggplot_build(x))
Expand Down
4 changes: 4 additions & 0 deletions man/benchplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5f868c5

Please sign in to comment.