extrColsDeX {wrMisc} | R 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 |
doExtractCols |
(logical) if default |
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
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"))
[Package wrMisc version 1.15.1 Index]