4

I am using R & R Studio on Linux Mint 13, and I am trying to get a string that looks like this:

domain\username

but when I do this:

usr <- "domain\\username"

the resulting variable usr appears with two \ in it:

#[1] "domain\\username"

Everything I have found indicates that this is the proper way to do this, yet, this is what I get. Any suggestions? Is there a setting askew?

GSee
  • 48,880
  • 13
  • 125
  • 145
wtribbey
  • 43
  • 1
  • 3

1 Answers1

4

may be the difference here between print and cat. So if you have the following string

usr <- "domain\\username"

and we go print(usr) we get

#[1] "domain\\username"

yet calling cat(usr) we get

#domain\username

which is what you're expecting correct? cat will actually evaluate the escapes, while print will just return the exact form of the object. You can test if your escapes are behaving as you think they should by using cat.

Check out the section on cat vs print here for a bit of info on it : R Inferno

DMT
  • 1,577
  • 10
  • 16
  • I appreciate the suggestion here. I discovered that the value I need to pass actually needs 4 \'s to be sent and received properly. This was helpful in getting to a solution for me. Thanks. – wtribbey Oct 09 '14 at 17:44