Is there a other version to make the first letter of each string capital and also with FALSE for flac perl?
name<-"hallo" gsub("(^[[:alpha:]])", "\\U\\1", name, perl=TRUE)
CamelCase Words are written without spaces, and the first letter of each word is capitalized. Also called Upper Camel Case or Pascal Casing.
Noun. initial caps (uncountable) (journalism, typography) A variant of title case in which every word begins with an upper-case letter and its other letters are lower-case.
The toUpperCase() method converts the string to uppercase.
You can try something like:
name<-"hallo" paste(toupper(substr(name, 1, 1)), substr(name, 2, nchar(name)), sep="")
Or another way is to have a function like:
firstup <- function(x) { substr(x, 1, 1) <- toupper(substr(x, 1, 1)) x }
Examples:
firstup("abcd") ## [1] Abcd firstup(c("hello", "world")) ## [1] "Hello" "World"
As pointed out in the comment, it is now possible to do: stringr::str_to_title("iwejofwe asdFf FFFF")
stringr
uses stringi
under the hood which takes care of complex internationalization, unicode, etc., you can do: stri_trans_totitle("kaCk, DSJAIDO, Sasdd.", opts_brkiter = stri_opts_brkiter(type = "sentence"))
There is a C or C++ library underneath stringi
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With