【发布时间】:2016-10-31 03:07:46
【问题描述】:
我有一个字符串,我想将它分成不同的部分。
test = c("3 CH • P" ,"9 CH • P" , "2 CH • P" , "2 CH, 5 ECH • V",
"3 ECH • V", "4 ECH • P" )
我知道使用str_split_fixed() from stringr() 可以根据某个字符拆分字符串。例如:
test.1 = str_split_fixed(test, c("•"), 2)
> test.1
[,1] [,2]
[1,] "3 CH " " P"
[2,] "9 CH " " P"
[3,] "2 CH " " P"
[4,] "2 CH, 5 ECH " " V"
[5,] "3 ECH " " V"
[6,] "4 ECH " " P"
但是,我想知道是否可以设置多个字符(例如,"•" 和",")来拆分字符串?
【问题讨论】:
标签: r string split fixed stringr