4
我想用兩個詞來分割字符串:分割字符串
s <- "PCB153 treated HepG2 cells at T18"
strsplit(s, split = <treated><at>)
我應該寫的,而不是<>什麼?
我會得到:
"PCB153" "HepG2 cells" "T18"
我想用兩個詞來分割字符串:分割字符串
s <- "PCB153 treated HepG2 cells at T18"
strsplit(s, split = <treated><at>)
我應該寫的,而不是<>什麼?
我會得到:
"PCB153" "HepG2 cells" "T18"
strsplit(s, split="treated|at")
#[[1]]
#[1] "PCB153 " " HepG2 cells " " T18"
您必須輸入它作爲一個字符串。拆就處理:
s <- "PCB153 treated HepG2 cells at T18"
s2 <- strsplit(s,split="treated")
unlist(s2)
拆就處理,並於:
unlist(strsplit(unlist(s2),split="at"))
我想用兩個詞來得到它的三個。 – charisz
我更新了答案。只需重複這些步驟。 – JT85
我從中學到了,怎麼走,謝謝。 – charisz