开发者

separate 1 string into more

Dear All, A have a string like this:

a <- "Good,Good*********,Good***********,Perfect,Perfect**********,Perf开发者_如何学运维ect***********"

now I want to separate this into this:

a <- c("Good","Good*********","Good***********","Perfect","Perfect**********","Perfect***********")

any suggestions are very welcome! Thanks you,

Lisanne


strsplit does this:

a<-"Good,Good***,Good****,Perfect,Perfect***,Perfect*****"
a <- strsplit(a, ",")[[1]]


This type of problem is a perfect candidate for scan:

scan(text = a, what = "", sep = ",")
# Read 6 items
# [1] "Good"               "Good*********"      "Good***********"    "Perfect"   
# [5] "Perfect**********"  "Perfect***********"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜