@@ -225,7 +225,7 @@ Facet <- ggproto("Facet", NULL,
225
225
# ' # Thanks to tidy eval idioms we now have another useful wrapper:
226
226
# ' p + wrap_cut(drat)
227
227
vars <- function (... ) {
228
- rlang :: quos(... )
228
+ quos(... )
229
229
}
230
230
231
231
@@ -278,29 +278,29 @@ as_facets_list <- function(x) {
278
278
if (inherits(x , " uneval" )) {
279
279
stop(" Please use `vars()` to supply facet variables" , call. = FALSE )
280
280
}
281
- if (rlang :: is_quosures(x )) {
282
- x <- rlang :: quos_auto_name(x )
281
+ if (is_quosures(x )) {
282
+ x <- quos_auto_name(x )
283
283
return (list (x ))
284
284
}
285
285
286
286
# This needs to happen early because we might get a formula.
287
287
# facet_grid() directly converted strings to a formula while
288
288
# facet_wrap() called as.quoted(). Hence this is a little more
289
289
# complicated for backward compatibility.
290
- if (rlang :: is_string(x )) {
291
- x <- rlang :: parse_expr(x )
290
+ if (is_string(x )) {
291
+ x <- parse_expr(x )
292
292
}
293
293
294
294
# At this level formulas are coerced to lists of lists for backward
295
295
# compatibility with facet_grid(). The LHS and RHS are treated as
296
296
# distinct facet dimensions and `+` defines multiple facet variables
297
297
# inside each dimension.
298
- if (rlang :: is_formula(x )) {
298
+ if (is_formula(x )) {
299
299
return (f_as_facets_list(x ))
300
300
}
301
301
302
302
# For backward-compatibility with facet_wrap()
303
- if (! rlang :: is_bare_list(x )) {
303
+ if (! is_bare_list(x )) {
304
304
x <- as_quoted(x )
305
305
}
306
306
@@ -316,9 +316,9 @@ as_facets_list <- function(x) {
316
316
317
317
# Flatten a list of quosures objects to a quosures object, and compact it
318
318
compact_facets <- function (x ) {
319
- x <- rlang :: flatten_if(x , rlang :: is_list )
320
- null <- vapply(x , rlang :: quo_is_null , logical (1 ))
321
- rlang :: new_quosures(x [! null ])
319
+ x <- flatten_if(x , is_list )
320
+ null <- vapply(x , quo_is_null , logical (1 ))
321
+ new_quosures(x [! null ])
322
322
}
323
323
324
324
# Compatibility with plyr::as.quoted()
@@ -327,29 +327,29 @@ as_quoted <- function(x) {
327
327
if (length(x ) > 1 ) {
328
328
x <- paste(x , collapse = " ; " )
329
329
}
330
- return (rlang :: parse_exprs(x ))
330
+ return (parse_exprs(x ))
331
331
}
332
332
if (is.null(x )) {
333
333
return (list ())
334
334
}
335
- if (rlang :: is_formula(x )) {
335
+ if (is_formula(x )) {
336
336
return (simplify(x ))
337
337
}
338
338
list (x )
339
339
}
340
340
# From plyr:::as.quoted.formula
341
341
simplify <- function (x ) {
342
- if (length(x ) == 2 && rlang :: is_symbol(x [[1 ]], " ~" )) {
342
+ if (length(x ) == 2 && is_symbol(x [[1 ]], " ~" )) {
343
343
return (simplify(x [[2 ]]))
344
344
}
345
345
if (length(x ) < 3 ) {
346
346
return (list (x ))
347
347
}
348
348
op <- x [[1 ]]; a <- x [[2 ]]; b <- x [[3 ]]
349
349
350
- if (rlang :: is_symbol(op , c(" +" , " *" , " ~" ))) {
350
+ if (is_symbol(op , c(" +" , " *" , " ~" ))) {
351
351
c(simplify(a ), simplify(b ))
352
- } else if (rlang :: is_symbol(op , " -" )) {
352
+ } else if (is_symbol(op , " -" )) {
353
353
c(simplify(a ), expr(- !! simplify(b )))
354
354
} else {
355
355
list (x )
@@ -371,29 +371,29 @@ as_facets <- function(x) {
371
371
return (x )
372
372
}
373
373
374
- if (rlang :: is_formula(x )) {
374
+ if (is_formula(x )) {
375
375
# Use different formula method because plyr's does not handle the
376
376
# environment correctly.
377
377
f_as_facets(x )
378
378
} else {
379
379
vars <- as_quoted(x )
380
- rlang :: as_quosures(vars , globalenv(), named = TRUE )
380
+ as_quosures(vars , globalenv(), named = TRUE )
381
381
}
382
382
}
383
383
f_as_facets <- function (f ) {
384
384
if (is.null(f )) {
385
- return (rlang :: as_quosures(list ()))
385
+ return (as_quosures(list ()))
386
386
}
387
387
388
- env <- rlang :: f_env(f ) %|| % globalenv()
388
+ env <- f_env(f ) %|| % globalenv()
389
389
390
390
# as.quoted() handles `+` specifications
391
391
vars <- as.quoted(f )
392
392
393
393
# `.` in formulas is ignored
394
394
vars <- discard_dots(vars )
395
395
396
- rlang :: as_quosures(vars , env , named = TRUE )
396
+ as_quosures(vars , env , named = TRUE )
397
397
}
398
398
discard_dots <- function (x ) {
399
399
x [! vapply(x , identical , logical (1 ), as.name(" ." ))]
@@ -406,7 +406,7 @@ is_facets <- function(x) {
406
406
if (! length(x )) {
407
407
return (FALSE )
408
408
}
409
- all(vapply(x , rlang :: is_quosure , logical (1 )))
409
+ all(vapply(x , is_quosure , logical (1 )))
410
410
}
411
411
412
412
@@ -422,8 +422,8 @@ eval_facets <- function(facets, data, env = globalenv()) {
422
422
tibble :: as_tibble(vars )
423
423
}
424
424
eval_facet <- function (facet , data , env = emptyenv()) {
425
- if (rlang :: quo_is_symbol(facet )) {
426
- facet <- as.character(rlang :: quo_get_expr(facet ))
425
+ if (quo_is_symbol(facet )) {
426
+ facet <- as.character(quo_get_expr(facet ))
427
427
428
428
if (facet %in% names(data )) {
429
429
out <- data [[facet ]]
@@ -433,7 +433,7 @@ eval_facet <- function(facet, data, env = emptyenv()) {
433
433
return (out )
434
434
}
435
435
436
- rlang :: eval_tidy(facet , data , env )
436
+ eval_tidy(facet , data , env )
437
437
}
438
438
439
439
layout_null <- function () {
0 commit comments