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'.
numPairDeColNames(
dat,
selComp = NULL,
stripTxt = NULL,
sep = "-",
columLabel = "conc",
sortByAbsRatio = FALSE,
silent = FALSE,
debug = FALSE,
callFrom = NULL
)
This function returns a matrix
(matrix or data.frame) main input
(character) the column index selected
(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)
(character, length=1) separator between pair of numeric values to extract
(character) column labels in output
(logical) optional sorting of output by (absolute) log-ratios (most extreme ratios on top)
(logical) suppress messages
(logical) additional messages for debugging
(character) allow easier tracking of messages produced
strsplit
and help on regex
## 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)
Run the code above in your browser using DataLab