I am looking for an efficient way to convert back slash to forward slash in R. Sometime I copy the link of the directory from the windows and I get something like this:
"\u used without hex digits in character string starting ""C:\u"
In R, you've to escape the
\\ So, your path should be:
x <- "C:\\Users\\jd\\Documents\\folder\\file.txt"
To get that, you can do:
x <- readline()
then, at the prompt, paste your unmodified path (CTRL+V then ENTER)
Finally, to change
/ everywhere, you could use
gsub, once again by escaping the
\, but twice, as follows:
gsub("\\\\", "/", x) #  "C:/Users/jd/Documents/folder/file.txt"