从COS统计论坛一个帖子的回复中抠出来的字符串操作总结:
#字符串连接:
paste() #paste(..., sep = " ", collapse = NULL)
#字符串分割:
strsplit() #strsplit(x, split, extended = TRUE, fixed = FALSE, perl = FALSE)
#计算字符串的字符数:
nchar()
#字符串截取:
substr(x, start, stop)
substring(text, first, last = 1000000)
substr(x, start, stop) <- value
substring(text, first, last = 1000000) <- value
#字符串替换及大小写转换:
chartr(old, new, x)
tolower(x)
toupper(x)
casefold(x, upper = FALSE)