numPairDeColNames: Extract pair of numeric values from vector or column-names

View source: R/numPairDeColNames.R

numPairDeColNamesR Documentation

Extract pair of numeric values from vector or column-names

Description

This function extracts a pair of numeric values out of a vector or colnames (from a matrix). This is useful when pairwise comparisons are concatenated like '10c-100c', return matrix with 'index'=selComp, log2rat and both numeric. Additional white space or character text can be removed via the argument stripTxt. Of course, the separator sep needs to be specified and should not be included to 'stripTxt'.

Usage

numPairDeColNames(
  dat,
  selComp = NULL,
  stripTxt = NULL,
  sep = "-",
  columLabel = "conc",
  sortByAbsRatio = FALSE,
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Arguments

dat

(matrix or data.frame) main input

selComp

(character) the column index selected

stripTxt

(character, max length=2) text to ignore, if NULL heading letter and punctuation characters will be removed; default will remove all letters (and following spaces)

sep

(character, length=1) separator between pair of numeric values to extract

columLabel

(character) column labels in output

sortByAbsRatio

(logical) optional sorting of output by (absolute) log-ratios (most extreme ratios on top)

silent

(logical) suppress messages

debug

(logical) additional messages for debugging

callFrom

(character) allow easier tracking of messages produced

Value

This function returns a matrix

See Also

strsplit and help on regex

Examples

##  composed column names
mat1 <- matrix(1:8, nrow=2, dimnames=list(NULL, paste0(1:4,"-",6:9)))
numPairDeColNames(mat1)
numPairDeColNames(colnames(mat1))
##  works also with simple numeric column names
mat2 <- matrix(1:8, nrow=2, dimnames=list(NULL, paste0("a",6:9)))
numPairDeColNames(mat2)

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