diff --git a/.travis.yml b/.travis.yml index a5bf180e6c..0349bff0f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,11 +18,11 @@ matrix: provider: script script: Rscript -e 'pkgdown::deploy_site_github(verbose = TRUE)' skip_cleanup: true - - r: oldrel + - r: 3.5 + - r: 3.4 + - r: 3.3 - r: 3.2 env: R_REMOTES_NO_ERRORS_FROM_WARNINGS=true - - r: 3.1 - env: R_REMOTES_NO_ERRORS_FROM_WARNINGS=true # environment variables set for all builds env: diff --git a/DESCRIPTION b/DESCRIPTION index 3a30d17cec..b7b8b39104 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,7 +17,7 @@ Authors@R: c( person("RStudio", role = c("cph")) ) Depends: - R (>= 3.1) + R (>= 3.2) Imports: digest, grDevices, @@ -27,7 +27,7 @@ Imports: MASS, mgcv, reshape2, - rlang (>= 0.3.0), + rlang (>= 0.3.1), scales (>= 0.5.0), stats, tibble, diff --git a/NAMESPACE b/NAMESPACE index 41405a260e..b541016163 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -118,6 +118,7 @@ S3method(widthDetails,titleGrob) S3method(widthDetails,zeroGrob) export("%+%") export("%+replace%") +export(":=") export(.data) export(.pt) export(.stroke) @@ -237,7 +238,9 @@ export(annotation_logticks) export(annotation_map) export(annotation_raster) export(arrow) +export(as_label) export(as_labeller) +export(as_name) export(autolayer) export(autoplot) export(benchplot) @@ -579,6 +582,15 @@ import(gtable) import(rlang) import(scales) importFrom(lazyeval,f_eval) +importFrom(rlang,":=") +importFrom(rlang,.data) +importFrom(rlang,as_label) +importFrom(rlang,as_name) +importFrom(rlang,enquo) +importFrom(rlang,enquos) +importFrom(rlang,expr) +importFrom(rlang,sym) +importFrom(rlang,syms) importFrom(stats,setNames) importFrom(tibble,tibble) importFrom(utils,.DollarNames) diff --git a/NEWS.md b/NEWS.md index 4699714a4a..db819b1ab3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,9 @@ extension developers if they have relied on internals that have been changed. This release also sees the addition of Hiroaki Yutani (@yutannihilation) to the core developer team. +With the release of R 3.6, ggplot2 now requires the R version to be at least 3.2, +as the tidyverse is committed to support 5 major versions of R. + ## New features * This release includes a range of internal changes that speeds up plot diff --git a/R/utilities-tidy-eval.R b/R/utilities-tidy-eval.R index 89b6032245..56458ce2b3 100644 --- a/R/utilities-tidy-eval.R +++ b/R/utilities-tidy-eval.R @@ -6,30 +6,55 @@ #' \code{\link[rlang]{syms}()} creates a list of symbols from a #' character vector. #' -#' * \code{\link[rlang]{expr}()} and \code{\link[rlang]{quo}()} quote -#' one expression. `quo()` wraps the quoted expression in a quosure. +#' * \code{\link[rlang]{enquo}()} and \code{\link[rlang]{enquos}()} +#' delay the execution of one or several function arguments. +#' \code{enquo()} returns a single quoted expression, which is like +#' a blueprint for the delayed computation. \code{enquos()} returns +#' a list of such quoted expressions. #' -#' The plural variants \code{\link[rlang]{exprs}()} and -#' \code{\link[rlang]{quos}()} return a list of quoted expressions or -#' quosures. +#' * \code{\link[rlang]{expr}()} quotes a new expression _locally_. It +#' is mostly useful to build new expressions around arguments +#' captured with [enquo()] or [enquos()]: +#' \code{expr(mean(!!enquo(arg), na.rm = TRUE))}. #' -#' * \code{\link[rlang]{enexpr}()} and \code{\link[rlang]{enquo}()} -#' capture the expression supplied as argument by the user of the -#' current function (`enquo()` wraps this expression in a quosure). +#' * \code{\link[rlang]{as_name}()} transforms a quoted variable name +#' into a string. Supplying something else than a quoted variable +#' name is an error. #' -#' \code{\link[rlang]{enexprs}()} and \code{\link[rlang]{enquos}()} -#' capture multiple expressions supplied as arguments, including -#' `...`. +#' That's unlike \code{\link[rlang]{as_label}()} which also returns +#' a single string but supports any kind of R object as input, +#' including quoted function calls and vectors. Its purpose is to +#' summarise that object into a single label. That label is often +#' suitable as a default name. +#' +#' If you don't know what a quoted expression contains (for instance +#' expressions captured with \code{enquo()} could be a variable +#' name, a call to a function, or an unquoted constant), then use +#' \code{as_label()}. If you know you have quoted a simple variable +#' name, or would like to enforce this, use \code{as_name()}. +#' +#' To learn more about tidy eval and how to use these tools, visit +#' \url{http://tidyeval.tidyverse.org} and the +#' \href{https://adv-r.hadley.nz/metaprogramming.html}{Metaprogramming +#' section} of \href{https://adv-r.hadley.nz}{Advanced R}. #' #' @md #' @name tidyeval #' @keywords internal -#' @aliases quo quos enquo enquos quo_name -#' sym ensym syms ensyms -#' expr exprs enexpr enexprs -#' .data -#' @export quo quos enquo enquos quo_name -#' @export sym ensym syms ensyms -#' @export expr enexpr enexprs -#' @export .data +#' @importFrom rlang expr enquo enquos sym syms .data := as_name as_label +#' @aliases expr enquo enquos sym syms .data := as_name as_label +#' @export expr enquo enquos sym syms .data := as_name as_label +NULL + + +#' Other tidy eval tools +#' +#' These tidy eval tools are no longer recommended for normal usage, +#' but are still exported for compatibility. See [`?tidyeval`][tidyeval] +#' for the recommended tools. +#' +#' @keywords internal +#' @name tidyeval-compat +#' @aliases quo quos quo_name ensym ensyms enexpr enexprs +#' @export quo quos quo_name ensym ensyms enexpr enexprs NULL diff --git a/man/tidyeval-compat.Rd b/man/tidyeval-compat.Rd new file mode 100644 index 0000000000..1a9c581d6c --- /dev/null +++ b/man/tidyeval-compat.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utilities-tidy-eval.R +\name{tidyeval-compat} +\alias{tidyeval-compat} +\alias{quo} +\alias{quos} +\alias{quo_name} +\alias{ensym} +\alias{ensyms} +\alias{enexpr} +\alias{enexprs} +\title{Other tidy eval tools} +\description{ +These tidy eval tools are no longer recommended for normal usage, +but are still exported for compatibility. See \code{\link[=tidyeval]{?tidyeval}} +for the recommended tools. +} +\keyword{internal} diff --git a/man/tidyeval.Rd b/man/tidyeval.Rd index b2f1b2edae..f78f9f5285 100644 --- a/man/tidyeval.Rd +++ b/man/tidyeval.Rd @@ -2,39 +2,50 @@ % Please edit documentation in R/utilities-tidy-eval.R \name{tidyeval} \alias{tidyeval} -\alias{quo} -\alias{quos} +\alias{expr} \alias{enquo} \alias{enquos} -\alias{quo_name} \alias{sym} -\alias{ensym} \alias{syms} -\alias{ensyms} -\alias{expr} -\alias{exprs} -\alias{enexpr} -\alias{enexprs} \alias{.data} +\alias{:=} +\alias{as_name} +\alias{as_label} \title{Tidy eval helpers} \description{ \itemize{ \item \code{\link[rlang]{sym}()} creates a symbol from a string and \code{\link[rlang]{syms}()} creates a list of symbols from a character vector. -\item \code{\link[rlang]{expr}()} and \code{\link[rlang]{quo}()} quote -one expression. \code{quo()} wraps the quoted expression in a quosure. +\item \code{\link[rlang]{enquo}()} and \code{\link[rlang]{enquos}()} +delay the execution of one or several function arguments. +\code{enquo()} returns a single quoted expression, which is like +a blueprint for the delayed computation. \code{enquos()} returns +a list of such quoted expressions. +\item \code{\link[rlang]{expr}()} quotes a new expression \emph{locally}. It +is mostly useful to build new expressions around arguments +captured with \code{\link[=enquo]{enquo()}} or \code{\link[=enquos]{enquos()}}: +\code{expr(mean(!!enquo(arg), na.rm = TRUE))}. +\item \code{\link[rlang]{as_name}()} transforms a quoted variable name +into a string. Supplying something else than a quoted variable +name is an error. -The plural variants \code{\link[rlang]{exprs}()} and -\code{\link[rlang]{quos}()} return a list of quoted expressions or -quosures. -\item \code{\link[rlang]{enexpr}()} and \code{\link[rlang]{enquo}()} -capture the expression supplied as argument by the user of the -current function (\code{enquo()} wraps this expression in a quosure). +That's unlike \code{\link[rlang]{as_label}()} which also returns +a single string but supports any kind of R object as input, +including quoted function calls and vectors. Its purpose is to +summarise that object into a single label. That label is often +suitable as a default name. -\code{\link[rlang]{enexprs}()} and \code{\link[rlang]{enquos}()} -capture multiple expressions supplied as arguments, including -\code{...}. +If you don't know what a quoted expression contains (for instance +expressions captured with \code{enquo()} could be a variable +name, a call to a function, or an unquoted constant), then use +\code{as_label()}. If you know you have quoted a simple variable +name, or would like to enforce this, use \code{as_name()}. } + +To learn more about tidy eval and how to use these tools, visit +\url{http://tidyeval.tidyverse.org} and the +\href{https://adv-r.hadley.nz/metaprogramming.html}{Metaprogramming +section} of \href{https://adv-r.hadley.nz}{Advanced R}. } \keyword{internal}