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***********"
精彩评论