0

I’m trying to connect with a database. I use the r-package “RODBC” and the password contains a backslash. Is there a possibility to handle this problem?

library(RODBC)
channel <- odbcConnect("database", uid="theuid", pwd=”whyisherea\backslash”, 
believeNRows=FALSE)
Bert
  • 1
  • 1
  • 1
    In R strings, backslash is an escape character. If you want to include a literal backslash, escape with a backslash, `"\\"`. Like `"this string has a single \\ backslash"`. You can use `cat` instead of `print` to see what's "really" there. – Gregor Thomas Feb 07 '18 at 17:34
  • 1
    As a side note, be careful of cutting and pasting from programs that autocorrect to fancy quotes - to mark strings in R you can use `"` or `'`, but not `”` or `“` like you have in your question around the `pwd` string. – Gregor Thomas Feb 07 '18 at 17:47

1 Answers1

0

You may define your string this way

pwd_string <- "whyisherea\\backslash"
Ekatef
  • 1,061
  • 1
  • 9
  • 12