R语言提取字符串的一部分substring函数

这个函数提取字符串的一部分。

语法

substring()函数的基本语法是:

substring(x,first,last)

以下是所使用的参数的说明:

  • x - 是字符向量输入。
  • first - 是第一个字符要被提取的位置。
  • last - 是最后一个字符要被提取的位置。

示例

# Extract characters from 5th to 7th position.
result <- substring("Extract", 5, 7)
print(result)

当我们上面的代码执行时,它产生以下结果:

[1] "act"
posted on 2017-08-06 10:43  csguo  阅读(58624)  评论(0编辑  收藏  举报