- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.1k
Open
Labels
Milestone
Description
This comment #3619 (comment) prompted me to look into plot_env, and as far as I can see it's stored and handed around just so it can be eventually given to the function combine_vars(), which then doesn't use it:
Lines 544 to 587 in e9b9946
| combine_vars <- function(data, env = emptyenv(), vars = NULL, drop = TRUE) { | |
| possible_columns <- unique(unlist(lapply(data, names))) | |
| if (length(vars) == 0) return(new_data_frame()) | |
| # For each layer, compute the facet values | |
| values <- compact(lapply(data, eval_facets, facets = vars, possible_columns = possible_columns)) | |
| # Form the base data.frame which contains all combinations of faceting | |
| # variables that appear in the data | |
| has_all <- unlist(lapply(values, length)) == length(vars) | |
| if (!any(has_all)) { | |
| missing <- lapply(values, function(x) setdiff(names(vars), names(x))) | |
| missing_txt <- vapply(missing, var_list, character(1)) | |
| name <- c("Plot", paste0("Layer ", seq_len(length(data) - 1))) | |
| abort(glue( | |
| "At least one layer must contain all faceting variables: {var_list(names(vars))}.\n", | |
| glue_collapse(glue("* {name} is missing {missing_txt}"), "\n", last = "\n") | |
| )) | |
| } | |
| base <- unique(rbind_dfs(values[has_all])) | |
| if (!drop) { | |
| base <- unique_combs(base) | |
| } | |
| # Systematically add on missing combinations | |
| for (value in values[!has_all]) { | |
| if (empty(value)) next; | |
| old <- base[setdiff(names(base), names(value))] | |
| new <- unique(value[intersect(names(base), names(value))]) | |
| if (drop) { | |
| new <- unique_combs(new) | |
| } | |
| base <- unique(rbind(base, df.grid(old, new))) | |
| } | |
| if (empty(base)) { | |
| abort("Faceting variables must have at least one value") | |
| } | |
| base | |
| } | 
Is this a hold-over from the times before tidy eval? Can we remove this/or assign
NULL here?Line 96 in 5a686c3
| plot_env = environment | 
It is already marked as deprecated in the documentation:
Line 35 in 5a686c3
| #' @param environment DEPRECATED. Used prior to tidy evaluation. | 
millerh1