R/internal-resolve_column.R

Defines functions resolve_column

Documented in resolve_column

#' @importFrom rlang sym enquo is_string is_symbol is_vector is_quosure as_name
NULL

#' Helper for evaluating column names, strings, or self-contained vectors
#'
#' Accepts:
#' - Unquoted column names (tidy-eval style)
#' - Quoted column names (as strings)
#' - Self-contained vectors
#'
#' @param arg A column name (unquoted or string) or a vector.
#'
#' @return A quosure, symbol, or literal vector depending on input.
#'
#' @keywords internal
resolve_column <- function(arg) {
  resolved <- NULL

  if (is_string(arg)) {
    resolved <- sym(arg)
  } else if (is_symbol(arg) || is_quosure(arg)) {
    resolved <- enquo(arg)
  } else if (is_vector(arg)) {
    return(arg)  # literal vector — skip validation
  } else {
    resolved <- enquo(arg)
  }

  return(resolved)
}

Try the MAPCtools package in your browser

Any scripts or data that you put into this service are public.

MAPCtools documentation built on June 25, 2025, 5:09 p.m.