GHRtools
  • Home
  • data4health
    • Overview
  • clim4health
    • Overview
  • GHRexplore
    • Overview
    • Reference
    • Changelog

    • Vignettes
    • Getting started
  • GHRmodel
    • Overview
    • Reference
    • Changelog

    • Vignettes
    • Getting started
    • Covariate structures
    • DLNMs in GHRmodel
  • GHRpredict
    • Overview
  • About GHR

On this page

  • Extract Covariate Names
    • Description
    • Arguments
    • Returns
    • Examples

Extract Covariate Names

Description

This function allows the user to select variables from a data set by prefix (using the pattern argument) or by exact name matching. The return object is a character vector with the selected covariate names that can be used as input for cov_add, cov_uni, cov_multi, cov_interact, cov_nl, and cov_varying functions.

extract_names(data = NULL, pattern = NULL, name = NULL)

Arguments

  • data: A data.frame containing the variables.
  • pattern: A character vector specifying prefix(es) to match (e.g., “tmin” matches “tmin”, “tmin.l1”, etc.).
  • name: A character vector of exact variable name(s) to extract.

Returns

A character vector of matched covariate names.

Examples

data <- data.frame(tmin = 1:10, tmin.l1 = 1:10, urban = 1:10)
extract_names(data, pattern = "tmin")
extract_names(data, name = "urban")
extract_names(data, pattern = "tmin", name = "urban")

Copyright 2025, GHR