是否有其他版本可以使每个字符串的第一个字母大写,并且对于 flac perl 也使用 FALSE ?
name<-"hallo"
gsub("(^[[:alpha:]])", "\\U\\1", name, perl=TRUE)
你可以尝试这样的事情:
name<-"hallo"
paste(toupper(substr(name, 1, 1)), substr(name, 2, nchar(name)), sep="")
或者另一种方法是具有如下功能:
firstup <- function(x) {
substr(x, 1, 1) <- toupper(substr(x, 1, 1))
x
}
例子:
firstup("abcd")
## [1] Abcd
firstup(c("hello", "world"))
## [1] "Hello" "World"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)