### Name: abbreviate ### Title: Abbreviate Strings ### Aliases: abbreviate ### Keywords: character ### ** Examples x <- c("abcd", "efgh", "abce") abbreviate(x, 2) abbreviate(x, 2, strict=TRUE)# >> 1st and 3rd are == "ab" (st.abb <- abbreviate(state.name, 2)) table(nchar(st.abb))# out of 50, 3 need 4 letters : as <- abbreviate(state.name, 3, strict=TRUE) as[which(as == "Mss")] ## Don't show: stopifnot(which(as == "Mss") == c(21,24,25)) ## End Don't show ## method="both.sides" helps: no 4-letters, and only 4 3-letters: st.ab2 <- abbreviate(state.name, 2, method="both") table(nchar(st.ab2)) ## Compare the two methods: cbind(st.abb, st.ab2)