【每天一个R语言命令】-strsplit

【描述】

Split the elements of a character vector x into substrings according to the matches to substring split within them.
根据分割符对字符串进行分割

【用法】

strsplit(x, split, fixed = FALSE, perl = FALSE, useBytes = FALSE)

【参数】

x   
character vector, each element of which is to be split. Other inputs, including a factor, will give an error.

split   
character vector (or object which can be coerced to such) containing regular expression(s) (unless fixed = TRUE) to use for splitting. If empty matches occur, in particular if split has length 0, x is split into single characters. If split has length greater than 1, it is re-cycled along x.

fixed   
logical. If TRUE match split exactly, otherwise use regular expressions. Has priority over perl.

perl    
logical. Should Perl-compatible regexps be used?

useBytes    
logical. If TRUE the matching is done byte-by-byte rather than character-by-character, and inputs with marked encodings are not converted. This is forced (with a warning) if any input is found which is marked as "bytes" (see Encoding).

【代码】

> strsplit('/usr/bin/R','/')
[[1]]
[1] ""    "usr" "bin" "R"  # 列表形式

> strsplit(c('/usr/bin/R', '/usr/bin/R'),'/')
[[1]]
[1] ""    "usr" "bin" "R"  

[[2]]
[1] ""    "usr" "bin" "R"  
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,513评论 0 13
  • Lua 5.1 参考手册 by Roberto Ierusalimschy, Luiz Henrique de F...
    苏黎九歌阅读 13,919评论 0 38
  • 51. 加法 不使用+、-,计算两数字之和 52. 至少有K个重复字符的最长子串 找到给定字符串(由小写字符组成)...
    毒死预言家的女巫阅读 660评论 0 0
  • 久违的晴天,家长会。 家长大会开好到教室时,离放学已经没多少时间了。班主任说已经安排了三个家长分享经验。 放学铃声...
    飘雪儿5阅读 7,575评论 16 22
  • 今天感恩节哎,感谢一直在我身边的亲朋好友。感恩相遇!感恩不离不弃。 中午开了第一次的党会,身份的转变要...
    迷月闪星情阅读 10,616评论 0 11