SortLength: Sort by Length

Description Usage Arguments Value Examples

View source: R/ShortFunctions.R

Description

Sort a character vector by the lengths of its elements

Usage

1
SortLength(x, decreasing = TRUE, na.last = NA)

Arguments

x

a character vector

decreasing

logical vector of length 1 indicating whether to keep NA elements. Defaults to TRUE

na.last

for controlling the treatment of NAs. If TRUE, missing values in the data are put last; if FALSE, they are put first; if NA, they are removed.

Value

A vector containing the elements of x sorted by length

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ex1 = c("Green", "Tech", "High", "Charter", "School")
ex2 = c(NA, NA, NA, "1 2 3", "6", "591", "A ")
SortLength(ex1)
SortLength(ex1, F)
SortLength(ex2)
SortLength(ex2, F)
SortLength(ex2, na.last = T)
SortLength(ex2, na.last = F)
SortLength(ex2, F, na.last = T)
SortLength(ex2, F, na.last = F)

debarros/dbTools documentation built on Sept. 18, 2020, 10:51 a.m.