I want to capitalise
every word of a sentence except the very first letter. There is a similar discussion here - Capitalize the first letter of both words in a two word string
So the function can be used as -
name <- c("zip code", "state", "final count")
simpleCap <- function(x) {
s <- strsplit(x, " ")[[1]]
paste(toupper(substring(s, 1,1)), substring(s, 2),
sep="", collapse=" ")
}
sapply(name, simpleCap)
But it also capitalise the first letter as well. I want something like "zip Code"
instead "Zip Code"
. Is there any way to achieve this?
Any help will be highly appreciated.