View source: R/sortBy2CategorAnd1intCol.R
sortBy2CategorAnd1IntCol | R Documentation |
This function sorts matrix 'mat' subsequently by categorical and numerical columns of 'mat', ie lines with identical values for categor are sorted by numeric value.
sortBy2CategorAnd1IntCol(
mat,
categCol,
numCol,
findNeighb = TRUE,
decreasing = FALSE,
silent = FALSE,
debug = FALSE,
callFrom = NULL
)
mat |
matrix (or data.frame) from which by 2 columns will be selected for sorting |
categCol |
(integer or character) which columns of 'mat' to be used as categorical columns |
numCol |
(integer or character) which column of 'mat' to be used as integer columns |
findNeighb |
(logical) if 'findNeighb' neighbour cols according to 'numCol' will be identified as groups & marked in new col 'neiGr', orphans marked as NA |
decreasing |
(logical) order of sort |
silent |
(logical) suppress messages |
debug |
(logical) additional messages for debugging |
callFrom |
(character) allow easier tracking of messages produced |
This function returns a sorted matrix (same dimensions as 'mat')
mat <- cbind(aa=letters[c(3,rep(7:8,3:4),4,4:6,7)],bb=LETTERS[rep(1:5,c(1,3,4,4,1))],
nu=c(23:21,23,21,22,18:12))
mat[c(3:5,1:2,6:9,13:10),]
sortBy2CategorAnd1IntCol(mat,cate=c("bb","aa"),num="nu",findN=FALSE,decr=TRUE)
sortBy2CategorAnd1IntCol(mat,cate=c("bb","aa"),num="nu",findN=TRUE,decr=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.