Disabling the slash in r doesn't work

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?

+3


source to share


1 answer


You don't actually have two backslashes - actually one character :-)

Check it:



a <- "\\"
nchar(a)
# [1] 1
cat(a)
# \

      

+6


source







All Articles