Problem with escape character in paste-function in R
This works:
&gt; paste(&quot;C:\\&quot;,filename,sep=&quot;&quot;)
[1] &quot;C:\\testfile.txt&quot;

Although you see TWO backslashes, there's really only one there, because usually when printed a backslash means &quot;the next character is encoding a special character&quot;. In this case the special character is literally a backslash.
You can see this by counting the number of characters in two backslashes:
&gt; nchar(&quot;\\&quot;)
[1] 1

And anyway you should probably be using file.path to construct paths and not fiddling around with backslashes:
&gt; file.path(&quot;C:&quot;,filename)
[1] &quot;C:/testfile.txt&quot;

(Note forward slashes here also work in Windows and don't suffer from having to be backslash-encoded).