@@ -297,7 +297,6 @@ resolve_labeller <- function(rows, cols, labels) {
297
297
# ' # your labeller to the right variable with labeller()
298
298
# ' p + facet_grid(cyl ~ am, labeller = labeller(am = to_string))
299
299
as_labeller <- function (x , default = label_value , multi_line = TRUE ) {
300
- if (is.formula(x )) x <- as_function(x )
301
300
force(x )
302
301
fun <- function (labels ) {
303
302
labels <- lapply(labels , as.character )
@@ -312,6 +311,8 @@ as_labeller <- function(x, default = label_value, multi_line = TRUE) {
312
311
x(labels )
313
312
} else if (is.function(x )) {
314
313
default(lapply(labels , x ))
314
+ } else if (is.formula(x )) {
315
+ default(lapply(labels , as_function(x )))
315
316
} else if (is.character(x )) {
316
317
default(lapply(labels , function (label ) x [label ]))
317
318
} else {
@@ -430,11 +431,6 @@ labeller <- function(..., .rows = NULL, .cols = NULL,
430
431
431
432
dots <- list (... )
432
433
433
- if (length(dots ) == 1 ) {
434
- if (is.formula(dots [[1 ]]) || is.function(dots [[1 ]]) && ! is_labeller(dots [[1 ]])) {
435
- return (as_labeller(dots [[1 ]]))
436
- }
437
- }
438
434
439
435
.default <- as_labeller(.default )
440
436
@@ -562,7 +558,11 @@ build_strip <- function(label_df, labeller, theme, horizontal) {
562
558
# '
563
559
# ' @noRd
564
560
assemble_strips <- function (grobs , theme , horizontal = TRUE , clip ) {
565
- if (length(grobs ) == 0 || is.zero(grobs [[1 ]])) return (grobs )
561
+ if (length(grobs ) == 0 || is.zero(grobs [[1 ]])) {
562
+ # Subsets matrix of zeroGrobs to correct length (#4050)
563
+ grobs <- grobs [seq_len(NROW(grobs ))]
564
+ return (grobs )
565
+ }
566
566
567
567
# Add margins to non-titleGrobs so they behave eqivalently
568
568
grobs [] <- lapply(grobs , function (g ) {
0 commit comments