extrColsDeX: Flexible extraction of columns

View source: R/extrColsDeX.R

extrColsDeXR Documentation

Flexible extraction of columns

Description

This function provides flexible checking if a set of columns may be extracted from a matrix or data.frame 'x'. If argument extrCol is list of character vectors, this allows to search among given options, the first matching name for each vector will be identified.

Usage

extrColsDeX(x, extrCol, doExtractCols = FALSE, callFrom = NULL, silent = FALSE)

Arguments

x

(matrix or data.frame) main input (where data should be extracted from)

extrCol

(character, integer or list) columns to be extracted, may be column-names or column index; if is list each first-level element will be considered as options for one choice

doExtractCols

(logical) if default FALSE only the column indexes will be returned

callFrom

(character) allows easier tracking of message(s) produced

silent

(logical) suppress messages

Value

integer-vector (ifdoExtractCols=FALSE return depending on input matrix or data.frame)

See Also

read.table, filterList

Examples

dFr <- data.frame(a=11:14, b=24:21, cc=LETTERS[1:4], dd=rep(c(TRUE,FALSE),2)) 
extrColsDeX(dFr,c("b","cc","notThere")) 
extrColsDeX(dFr,c("b","cc","notThere"), doExtractCols=TRUE) 
extrColsDeX(dFr, list(c("nn","b","a"), c("cc","a"),"notThere")) 

wrMisc documentation built on Sept. 11, 2024, 6:10 p.m.