R/subset.varlist.r

Defines functions subset.varlist

Documented in subset.varlist

#' generate a varlist that is a subset of another
#'
#' @param x a varlist
#' @param vars a set of variable names
#' @param ... currently ignored
#' @return returns the subset of variable names with an attibute "type" giving the types.  The vector is of class "varlist"
#' @export
subset.varlist <- function(x, vars, ...)
{
  vars <- gvcharexpr(enquo(vars))
  names <- x[x %in% vars]
  attr(names, "type") <- attr(x,"type")[x %in% vars]
  class(names) <- "varlist"
  return (names)
}

Try the genvar package in your browser

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

genvar documentation built on Jan. 21, 2020, 9:07 a.m.