Is there a builtin functionality in R to sort character vectors taking case into account? sort
and order
ignore the case:
tv <- c("a", "A", "ab", "B")
sort(tv)
## [1] "a" "A" "ab" "B"
This is my solution so far:
CAPS <- grep("^[A-Z]", tv)
c(sort(tv[CAPS]), sort(tv[-CAPS]))
## [1] "A" "B" "a" "ab"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…