我想用两个单词分割一个字符串:
s <- "PCB153 treated HepG2 cells at T18"
strsplit(s, split = <treated><at>)
我应该写什么而不是&lt;&gt;?
我会得到:
"PCB153" "HepG2 cells" "T18"
答案 0 :(得分:9)
strsplit(s, split="treated|at")
#[[1]]
#[1] "PCB153 " " HepG2 cells " " T18"
答案 1 :(得分:1)
您必须以字符串形式输入。拆分处理:
s <- "PCB153 treated HepG2 cells at T18"
s2 <- strsplit(s,split="treated")
unlist(s2)
拆分处理和at:
unlist(strsplit(unlist(s2),split="at"))