I have a string "California Art Craft Painting Society" and I want to write a function x in R that can turn any string into an acronym "CACPS". I used the following code:
acronym <- function(x){
abbreviate(x)
}
Is there a way to write the function using stringr such as strsplit the string first, then use strsub to pull the first letter of each word (not use abbreviate)?
If you want to use string split approach, try this
Or using
stringr
: