R语言 从字符向量中提取子串 – substring() 函数
R编程语言中的 substring() 函数是用来提取字符向量中的子串的。你可以轻松地从给定的字符串中提取所需的子串或字符。
语法: substring(text, first, last)
参数
- text: 字符向量
- first: 整数,要被替换的第一个元素
- last: 整数,要替换的最后一个元素。
R – substring() 函数示例
例1:用R编程语言中的substring函数提取数值
输出:
例2:在R编程语言的字符串函数中用子串提取数值
输出
例3:使用substring()函数在R中替换字符串
输出