Symbol "|" in strsplit function (vertical strip / pipe)
1 answer
This is because the split argument is interpreted as a regular expression, and | - a special character in regular expression.
To get around this, you have two options:
Option 1: Escape | , i.e. split = "\\|"
strsplit("ty|rr", split = "\\|") [[1]] [1] "ty" "rr" Option 2: Specify fixed = TRUE :
strsplit("ty|rr", split = "|", fixed = TRUE) [[1]] [1] "ty" "rr" Also see the See Also section ?strsplit , which says what you read ?"regular expression" for more information on the template specification.
+13