0

I have had an issue regarding splitting the string having | in R. How can I separate abc and def in this case? Thank you all for your help.

> str_split("abc|def", "|")
[[1]]
[1] ""  "a" "b" "c" "|" "d" "e" "f" "" 

> str_split("abc|def", ".|.")
[[1]]
[1] "" "" "" "" "" "" "" ""
Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294

1 Answers1

1

Here a solution with base R

unlist(strsplit("abc|def", split = "|",fixed = TRUE))
Vinícius Félix
  • 8,448
  • 6
  • 16
  • 32