Learn R Programming

GHRmodel (version 0.1.1)

cov_uni: Build Univariable Covariate Sets

Description

This function returns a list where each element contains a single covariate, based on covariates specified in the pattern or name arguments. This structure is suitable for generating separate univariable model formulas using write_inla_formulas.

Usage

cov_uni(covariates = NULL, pattern = NULL, name = NULL)

Value

A list of character vectors, each of length 1, containing the matched covariate name. The resulting list is suitable for use as the covariates argument in write_inla_formulas.

Arguments

covariates

A character vector of covariate names. Typically the output from extract_names.

pattern

A character vector specifying the prefix pattern(s) to match (e.g., "tmin" matches "tmin", "tmin.l1", etc.).

name

A character vector specifying exact variable name(s) to extract.

Examples

Run this code
data <- data.frame(tmin = rnorm(10), tmin.l1 = rnorm(10), urban = rnorm(10))
covs <- extract_names(data, pattern = "tmin", name = "urban")
cov_uni(covs, pattern = "tmin")
cov_uni(covs, name = "urban")

Run the code above in your browser using DataLab