sortBy2CategorAnd1IntCol
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,
callFrom = NULL
)
matrix (or data.frame) from which by 2 columns will be selected for sorting
(integer or character) which columns of 'mat' to be used as categorical columns
(integer or character) which column of 'mat' to be used as integer columns
(logical) if 'findNeighb' neighbour cols according to 'numCol' will be identified as groups & marked in new col 'neiGr', orphans marked as NA
(logical) order of sort
(logical) suppress messages
(character) allow easier tracking of message(s) produced
sorted matrix (same dimensions as 'mat')
# NOT RUN {
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)
# }
Run the code above in your browser using DataLab