R 字符串分割(strings split)

2019-12-05  本文已影响0人  夏夏LJ

stringr package

str_split(string, pattern, n = Inf, simplify = FALSE)

str_split_fixed(string, pattern, n)

str_split_n(string, pattern, n)

https://stringr.tidyverse.org/reference/str_split.html#examples

stringi package

stri_split(str, ..., regex, fixed, coll, charclass)

stri_split_fixed(str, pattern, n = -1L, omit_empty = FALSE,

tokens_only = FALSE, simplify = FALSE, ..., opts_fixed = NULL)

stri_split_regex(str, pattern, n = -1L, omit_empty = FALSE,

tokens_only = FALSE, simplify = FALSE, ..., opts_regex = NULL)

stri_split_coll(str, pattern, n = -1L, omit_empty = FALSE,

tokens_only = FALSE, simplify = FALSE, ..., opts_collator = NULL)

stri_split_charclass(str, pattern, n = -1L, omit_empty = FALSE,

tokens_only = FALSE, simplify = FALSE)

http://www.gagolewski.com/software/stringi/manual/?manpage=stri_split

我是在处理数据的时候发现使用str_split之后得到的结果是有差异,因为想要弄清楚这些不同的分割函数都有啥不同,大家还是看原始R包的解释比较清楚,做一个搬运工很开心。

但是我都没有使用这两个,因为str_split 返回的list不适用我接下来的操作,因此使用了stringr 包里面的Word函数:
word(string, start = 1L, end = start, sep = fixed(" "))
然后就可以得到我想要的结果啦。

上一篇下一篇

猜你喜欢

热点阅读