Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

numPairDeColNames

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,
  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

callFrom

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

Value

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

Analyze Experimental High-Throughput (Omics) Data

v1.5.4
GPL-3
Authors
Wolfgang Raffelsberger [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.