View source: R/misc_functions.R
match_colnames_pattern | R Documentation |
'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'
match_colnames_pattern(dtb, ...)
dtb |
A data.table from which the column names |
... |
A list of the names to match with the data.table ones. Needs to be made of character otherwise the function stops |
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"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.