4

我想用两个词分割一个字符串:

s <- "PCB153 treated HepG2 cells at T18"
strsplit(s, split = <treated><at>)

我应该写什么而不是<>?

我会得到:

"PCB153" "HepG2 cells" "T18"
4

2 回答 2

9
strsplit(s, split="treated|at")
#[[1]]
#[1] "PCB153 "       " HepG2 cells " " T18" 
于 2014-03-26T10:46:34.280 回答
1

您必须将其作为字符串输入。拆分处理:

s <- "PCB153 treated HepG2 cells at T18"
s2 <- strsplit(s,split="treated")
unlist(s2)

拆分处理和在:

unlist(strsplit(unlist(s2),split="at"))
于 2014-03-26T10:36:12.253 回答