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

语法

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

substring(x,first,last)

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

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

示例

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

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

[1] "act"

相关文章:

  • 2022-12-23
  • 2021-10-22
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-02-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2021-07-19
相关资源
相似解决方案