I\'m writing strings which contain backslashes (\\) to a file:
x1 = "\\\\str"
x2 = "\\\\\\str"
# Error: \'\\s\' is an unreco
Note that the doubling of backslashes is because you are entering the string at the command line and the string is first parsed by the R parser. You can enter strings in different ways, some of which don't need the doubling. For example:
> tmp <- scan(what='')
1: \\\\\str
2:
Read 1 item
> print(tmp)
[1] "\\\\\\\\\\str"
> cat(tmp, '\n')
\\\\\str
>