R 字符操作函数

函数 描述
nchar(x) 计算x中的字符数量
substr(x, start, stop) 字符串截取
grep(pattern, x) 字符串内的查找
paste(…, sep = “ ”, collapse = NULL) 字符串连接
strsplit(x, split) 字符串分割
tolower() 把x变成小写
toupper(x) 把x变成大写
casefold(x, upper = FALSE) 通过指定upper,把x变成大写或者小写
chartr(old, new, x) 把x中每个在old中出现的字符翻译成new中相应位置的字符