3

I have read that if you want to insert a backslash in a string you need to escape it:

a <- "\\"

The problem is that if I do that I get two slashes in my string!

> a <- "\\"
> a
[1] "\\"

How can I get just one single backslash in my string?

Dario Lacan
  • 1,099
  • 1
  • 11
  • 25

1 Answers1

6

You don't actually get two backslashes--that's actually a single character :-)

Test it out:

a <- "\\"
nchar(a)
# [1] 1
cat(a)
# \
A5C1D2H2I1M1N2O1R2T1
  • 190,393
  • 28
  • 405
  • 485