match_colnames_pattern: Obtain matching names corresponding to patterns

View source: R/misc_functions.R

match_colnames_patternR Documentation

Obtain matching names corresponding to patterns

Description

'match_colnames_pattern' returns the matching names of the argument 'dtb' (i.e. names(dtb)) corresponding to the regular expression patterns provided. The patterns must be supported by grep. This is based on 'data.table:::patterns'

Usage

match_colnames_pattern(dtb, ...)

Arguments

dtb

A data.table from which the column names names(dtb) or colnames(dtb) will be tested

...

A list of the names to match with the data.table ones. Needs to be made of character otherwise the function stops

Examples

library(data.table)
library(CKutils)
dtb <- data.table(id = c("city", "year", "birth", "idp"), b = c("age", "year", "bp", "name"))
z <- list("id", "year", "b")
match_colnames_pattern(dtb, z) #[1] "id" "b"

ChristK/CKutils documentation built on April 11, 2025, 10:11 p.m.