@@ -530,11 +530,20 @@ combine_vars <- function(data, env = emptyenv(), vars = NULL, drop = TRUE) {
530
530
# For each layer, compute the facet values
531
531
values <- compact(plyr :: llply(data , eval_facets , facets = vars , env = env ))
532
532
533
- # Form the base data frame which contains all combinations of faceting
533
+ # Form the base data. frame which contains all combinations of faceting
534
534
# variables that appear in the data
535
- has_all <- unlist(plyr :: llply (values , length )) == length(vars )
535
+ has_all <- unlist(lapply (values , length )) == length(vars )
536
536
if (! any(has_all )) {
537
- stop(" At least one layer must contain all variables used for faceting" )
537
+ missing <- lapply(values , function (x ) setdiff(names(vars ), names(x )))
538
+ missing_txt <- vapply(missing , var_list , character (1 ))
539
+ name <- c(" Plot" , paste0(" Layer " , seq_len(length(data ) - 1 )))
540
+
541
+ stop(
542
+ " At least one layer must contain all faceting variables: " ,
543
+ var_list(names(vars )), " .\n " ,
544
+ paste0(" * " , name , " is missing " , missing_txt , collapse = " \n " ),
545
+ call. = FALSE
546
+ )
538
547
}
539
548
540
549
base <- unique(plyr :: ldply(values [has_all ]))
0 commit comments