whichcol: Which column

View source: R/whichcol.R

whichcolR Documentation

Which column

Description

Retrieves column names and labels that matches a general expression via grepl.

Usage

whichcol(pattern, tibble, label = TRUE, ignore.case = TRUE, ...)

Arguments

pattern

character string containing a regular expression (or character string for fixed = TRUE) to be matched in the given character vector. Coerced by as.character to a character string if possible. If a character vector of length 2 or more is supplied, the first element is used with a warning. Missing values are allowed except for regexpr, gregexpr and regexec.

tibble

a tibble object.

label

a logical value indicating if pattern should be searched in variable label, instead of variable name. Default is TRUE.

ignore.case

if FALSE, the pattern matching is case sensitive and if TRUE, case is ignored during matching.

...

Arguments passed on to base::grepl

perl

logical. Should Perl-compatible regexps be used?

fixed

logical. If TRUE, pattern is a string to be matched as is. Overrides all conflicting arguments.

useBytes

logical. If TRUE the matching is done byte-by-byte rather than character-by-character. See ‘Details’.

Value

A data frame.

Examples

# tibble generated by haven
input <- system.file("extdata/reds", package = "ILSAmerge")
x <- do.call(rbind,justload(inputdir = input,population = "BCGV1"))
x

whichcol("weight",x)


ILSAmerge documentation built on April 11, 2025, 5:54 p.m.