I'm trying to convert all data in the column to "First letter to upper case" The following code replaces all data with the first row,
simpleCap <- function(x) {
s <- strsplit(x, " ")[[1]]
paste(toupper(substring(s, 1,1)), substring(s, 2),
sep="", collapse=" ")
}
allDestination$Categories <- simpleCap(allDestination$Categories)
Sample data
japan/okinawa/okinawa-other-islands
japan/hokkaido/hokkaido-north/furano-biei-tomamu
japan/hokkaido/hokkaido-north/asahikawa-sounkyo
japan/hokkaido/hokkaido-north/wakkanai-rishiri-rebun
japan/hokkaido/hokkaido-east/kushiro-akan-nemuro
The function code sample comes from First letter to upper case
How to make the function as "column compatible" instead of only replacing only a single value?