R/sortVector.R

Defines functions `sortVector`

 ## function to sort a vector of strings according to their length

`sortVector` <- 
function(x, collapse = "") {
    strx <- strsplit(x, split=ifelse(collapse == "", "", "\\*"))
    strings <- NULL
    lengths <- unlist(lapply(strx, length))
    unique.lengths <- sort(unique(lengths))
    for (i in seq(length(unique.lengths))) {
        strings <- c(strings, sort(x[which(lengths == unique.lengths[i])]))
    }
    return(strings)
}

Try the QCApro package in your browser

Any scripts or data that you put into this service are public.

QCApro documentation built on May 1, 2019, 10:09 p.m.