Skip to contents

Get names by string matching

Usage

getnames(
  x,
  pattern = NULL,
  starts_with = NULL,
  ends_with = NULL,
  ignore_case = TRUE
)

getnumericnames(x)

getlogicalnames(x)

getcharacternames(x)

getdatenames(x)

Arguments

x

object with names() method.

pattern

Character: pattern to match anywhere in names of x.

starts_with

Character: pattern to match in the beginning of names of x.

ends_with

Character: pattern to match at the end of names of x.

ignore_case

Logical: If TRUE, well, ignore case.

Value

Character vector of matched names.

Details

pattern, starts_with, and ends_with are applied sequentially. If more than one is provided, the result will be the intersection of all matches.

Author

EDG

Examples

getnames(iris, starts_with = "Sepal")
#> [1] "Sepal.Length" "Sepal.Width" 
getnames(iris, ends_with = "Width")
#> [1] "Sepal.Width" "Petal.Width"