ref: [R字符串] 字符串长度、分割、拼接、截取、替代、匹配和大小写替换
ref: R String Manipulation Functions
1. nchar()
With the help of this function, we can count the characters. This function consists of a character vector as its argument which then returns a vector comprising of different sizes of the elements of x. nchar is the fastest way to find out if elements of a character vector are non-empty strings or not.
> str <- "Big Data at DataFlair"
> nchar(str)
2. paste()
We can concatenate n number of strings using the paste() function.
> #Author DataFlair
> paste("Hadoop", "Spark", "and", "Flink")
3. substr()
It is the substrings of a character vector. The extractor replaces substrings in a character vector.
#Author DataFlair
> num <- "12345678"
> substr(num, 4, 5)
> substr(num, 5, 7)
标签:Functions,num,String,character,849,substr,vector From: https://www.cnblogs.com/alex-bn-lee/p/17515742.html