Here,
> r<-c("AAandBB", "BBandCC")
> strsplit(as.character(r),'and')
[[1]]
[1] "AA" "BB"
[[2]]
[1] "BB" "CC"
Working well, but
> r<-c("AA|andBB", "BB|andCC")
> strsplit(as.character(r),'|and')
[[1]]
[1] "A" "A" "|" "" "B" "B"
[[2]]
[1] "B" "B" "|" "" "C" "C"
Here, the answer is not correct. How to get "AA" and "BB", when I use '|and'?
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…