diff --git a/R/assets-funs.R b/R/assets-funs.R index 35e10494..e35d0a47 100644 --- a/R/assets-funs.R +++ b/R/assets-funs.R @@ -342,10 +342,7 @@ assets_select <- function(items, ..., asset_names = NULL, select_fn = NULL) { assets_select.doc_item <- function(items, ..., asset_names = NULL, select_fn = NULL) { - exprs <- unquote( - expr = as.list(substitute(list(...), env = environment())[-1]), - env = parent.frame() - ) + exprs <- as.list(substitute(list(...), env = environment()))[-1] init_length <- length(items$assets) if (!is.null(asset_names)) { asset_names <- intersect(names(items$assets), asset_names) @@ -354,9 +351,10 @@ assets_select.doc_item <- function(items, ..., if (length(exprs) > 0) { if (!is.null(names(exprs))) .error("Select expressions cannot be named.") - for (i in seq_along(exprs)) { + for (expr in exprs) { + expr <- unquote(expr = expr, env = parent.frame()) sel <- map_lgl(names(items$assets), function(key) { - select_eval(key = key, asset = items$assets[[key]], expr = exprs[[i]]) + select_eval(key = key, asset = items$assets[[key]], expr = expr) }) items$assets <- items$assets[sel] } diff --git a/R/items-funs.R b/R/items-funs.R index 298c5484..87338ef5 100644 --- a/R/items-funs.R +++ b/R/items-funs.R @@ -477,15 +477,13 @@ items_filter <- function(items, ..., filter_fn = NULL) { #' @export items_filter.doc_items <- function(items, ..., filter_fn = NULL) { init_length <- items_length(items) - exprs <- unquote( - expr = as.list(substitute(list(...), env = environment())[-1]), - env = parent.frame() - ) + exprs <- as.list(substitute(list(...), env = environment()))[-1] if (length(exprs) > 0) { if (!is.null(names(exprs))) .error("Filter expressions cannot be named.") - for (i in seq_along(exprs)) { - sel <- map_lgl(items$features, eval_filter_expr, expr = exprs[[i]]) + for (expr in exprs) { + expr <- unquote(expr = expr, env = parent.frame()) + sel <- map_lgl(items$features, eval_filter_expr, expr = expr) items$features <- items$features[sel] } } diff --git a/R/static-funs.R b/R/static-funs.R index dd94cec8..eb61e065 100644 --- a/R/static-funs.R +++ b/R/static-funs.R @@ -227,12 +227,10 @@ links <- function(x, ...) { #' @export links.rstac_doc <- function(x, ...) { - exprs <- unquote( - expr = as.list(substitute(list(...), env = environment())[-1]), - env = parent.frame() - ) + exprs <- as.list(substitute(list(...), env = environment()))[-1] sel <- !logical(length(x$links)) for (expr in exprs) { + expr <- unquote(expr = expr, env = parent.frame()) sel <- sel & map_lgl(x$links, function(x) { tryCatch( eval(expr, envir = x),