Skip to content

Commit 4463da6

Browse files
authored
Eliminate remotes (#2572)
* Eliminate dev rlang dependency * Bump to released scales * Update docs
1 parent 0b71743 commit 4463da6

File tree

7 files changed

+54
-12
lines changed

7 files changed

+54
-12
lines changed

DESCRIPTION

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Imports:
2626
mgcv,
2727
plyr (>= 1.7.1),
2828
reshape2,
29-
rlang (>= 0.2.0.9001),
30-
scales (>= 0.4.1.9002),
29+
rlang,
30+
scales (>= 0.5.0),
3131
stats,
3232
tibble,
3333
viridisLite,
@@ -54,9 +54,6 @@ Suggests:
5454
rmarkdown,
5555
sf (>= 0.3-4),
5656
svglite (>= 1.2.0.9001)
57-
Remotes:
58-
hadley/scales,
59-
r-lib/rlang
6057
Enhances: sp
6158
License: GPL-2 | file LICENSE
6259
URL: http://ggplot2.tidyverse.org, https://github.com/tidyverse/ggplot2
@@ -88,6 +85,7 @@ Collate:
8885
'backports.R'
8986
'bench.r'
9087
'bin.R'
88+
'compat-quosures.R'
9189
'coord-.r'
9290
'coord-cartesian-.r'
9391
'coord-fixed.r'

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ S3method("$",ggproto)
44
S3method("$",ggproto_parent)
55
S3method("$<-",uneval)
66
S3method("+",gg)
7+
S3method("[",quosures)
78
S3method("[",uneval)
89
S3method("[<-",uneval)
910
S3method("[[",ggproto)
@@ -12,6 +13,7 @@ S3method(.DollarNames,ggproto)
1213
S3method(as.list,ggproto)
1314
S3method(autolayer,default)
1415
S3method(autoplot,default)
16+
S3method(c,quosures)
1517
S3method(drawDetails,zeroGrob)
1618
S3method(element_grob,element_blank)
1719
S3method(element_grob,element_line)
@@ -95,6 +97,7 @@ S3method(print,ggplot)
9597
S3method(print,ggplot2_bins)
9698
S3method(print,ggproto)
9799
S3method(print,ggproto_method)
100+
S3method(print,quosures)
98101
S3method(print,rel)
99102
S3method(print,theme)
100103
S3method(print,uneval)

R/compat-quosures.R

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# TODO: Remove once rlang 0.2.0.9001 or later is on CRAN
2+
3+
new_quosures <- function(x) {
4+
if (!rlang::is_list(x)) {
5+
stop("Expected a list of quosures")
6+
}
7+
structure(x,
8+
class = "quosures",
9+
names = rlang::names2(x)
10+
)
11+
}
12+
13+
as_quosures <- function(x, env, named = FALSE) {
14+
x <- lapply(x, rlang::as_quosure, env = env)
15+
if (named) {
16+
x <- rlang::quos_auto_name(x)
17+
}
18+
new_quosures(x)
19+
}
20+
21+
is_quosures <- function(x) {
22+
inherits(x, "quosures")
23+
}
24+
25+
#' @export
26+
`[.quosures` <- function(x, i) {
27+
structure(NextMethod(), class = "quosures")
28+
}
29+
#' @export
30+
c.quosures <- function(..., recursive = FALSE) {
31+
new_quosures(NextMethod())
32+
}
33+
#' @export
34+
print.quosures <- function(x, ...) {
35+
print(unclass(x), ...)
36+
}

R/facet-.r

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ as_facets_list <- function(x) {
323323
# Compatibility with plyr::as.quoted()
324324
as_quoted <- function(x) {
325325
if (is.character(x)) {
326+
if (length(x) > 1) {
327+
x <- paste(x, collapse = "; ")
328+
}
326329
return(rlang::parse_exprs(x))
327330
}
328331
if (is.null(x)) {
@@ -381,12 +384,12 @@ as_facets <- function(x) {
381384
f_as_facets(x)
382385
} else {
383386
vars <- as_quoted(x)
384-
rlang::as_quosures(vars, globalenv(), named = TRUE)
387+
as_quosures(vars, globalenv(), named = TRUE)
385388
}
386389
}
387390
f_as_facets <- function(f) {
388391
if (is.null(f)) {
389-
return(rlang::as_quosures(list()))
392+
return(as_quosures(list()))
390393
}
391394

392395
env <- rlang::f_env(f) %||% globalenv()
@@ -397,7 +400,7 @@ f_as_facets <- function(f) {
397400
# `.` in formulas is ignored
398401
vars <- discard_dots(vars)
399402

400-
rlang::as_quosures(vars, env, named = TRUE)
403+
as_quosures(vars, env, named = TRUE)
401404
}
402405
discard_dots <- function(x) {
403406
x[!vapply(x, identical, logical(1), as.name("."))]

R/facet-wrap.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed",
114114

115115
# Flatten all facets dimensions into a single one
116116
facets_list <- as_facets_list(facets)
117-
facets <- rlang::flatten_if(facets_list, is.list)
117+
facets <- rlang::flatten_if(facets_list, rlang::is_list)
118118

119119
ggproto(NULL, FacetWrap,
120120
shrink = shrink,

R/plot-build.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ ggplot_gtable.ggplot_built <- function(data) {
275275
if (length(tag_pos) == 2) tag_pos <- "manual"
276276
valid_pos <- c("topleft", "top", "topright", "left", "right", "bottomleft",
277277
"bottom", "bottomright")
278+
278279
if (!(tag_pos == "manual" || tag_pos %in% valid_pos)) {
279280
stop("plot.tag.position should be a coordinate or one of ",
280281
paste(valid_pos, collapse = ', '), call. = FALSE)

man/ggplot2-package.Rd

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)