strsplit in R with metacharacter
- by user1429852
I have received a large amount of data where the delimiter is a backslash (obviously a bad choice). I'm processing it in R for computation, and having a hard time finding how to split the string since the backslash is a metacharacter. For example, a string would look like this:
"1128\0019\XA5\E2R\366\00=15"
and I want to split it along the "\" character, but when I run the strsplit command:
strsplit(tempStr, "\")
Error in strsplit(tempStr, "\") :
invalid regular expression '\', reason 'Trailing backslash'
When I try to used the "fixed" option, it does not run because it is expecting something after the backslash:
strsplit(tempStr, "\", fixed = TRUE)
Unfortunately, I can't preprocess the data with another program because the data is generated daily. Please help and thanks!