ColSeeker: Find numeric index and names of columns based on class(es)...

View source: R/basefunctions.R

ColSeekerR Documentation

Find numeric index and names of columns based on class(es) and patterns

Description

ColSeeker looks up colnames (by default for tibble rawdata) based on type and parts of names, using regular expressions. Be warned that special characters as e.g. [ ( need to be escaped or replaced by . Exclusion rules may be specified as well.

Usage

ColSeeker(
  data = rawdata,
  namepattern = ".",
  varclass = NULL,
  exclude = NULL,
  excludeclass = NULL,
  casesensitive = TRUE,
  returnclass = FALSE
)

Arguments

data

tibble or data.frame, where columns are to be found; by default rawdata

namepattern

Vector of pattern to look for.

varclass

Vector, only columns of defined class(es) are returned

exclude

Vector of pattern to exclude from found names.

excludeclass

Vector, exclude columns of specified class(es)

casesensitive

Logical if case is respected in matching (default FALSE: a<>A)

returnclass

Logical if classes should be included in output

Value

A list with index, names, backticked names, and count; optionally the classes as well

Examples

ColSeeker(data = mtcars, namepattern = c("^c", "g"))
ColSeeker(data = mtcars, namepattern = c("^c", "g"), exclude = "r")
assign("rawdata", mtcars)
ColSeeker(namepattern = c("^c", "g"), varclass="numeric")
num_int_data <- data.frame(num1=rnorm(10), num2=runif(10), int1=1:10, int2=11:20)
ColSeeker(num_int_data, varclass="numeric")  # integers are not found
ColSeeker(num_int_data, varclass=c("numeric","integer")) 

wrappedtools documentation built on Oct. 10, 2024, 5:07 p.m.