I read that if you want to insert a backslash in a string, you need to avoid it:
a <- "\\"
The problem is, if I do this, I get two slashes in my string!
> a <- "\\" > a [1] "\\"
How can I only get one backslash in my string?
You don't actually have two backslashes - actually one character :-)
Check it:
a <- "\\" nchar(a) # [1] 1 cat(a) # \