Early in my R life I discovered the pain of R and windows being on different pages when it came to the separator between directories and subdirectories. Eventhough I know about
I've adapted the following autohotkey code shared to replace all backslashes with forward slashes whenever I paste anything in RStudio. There are pros and cons to this approach.
Pros: You don't have to think about it. The code will only run if the active window is RStudio.
Cons: The code is called every time you paste something in R. Each time it attempts to find backslashes and replace them with forward slashes.
GroupAdd, R, RStudio
;replaces backslashes with forward slashes in a file name that is stored on the clipboard
#IfWinActive ahk_group R
^v::
StringReplace,clipboard,clipboard,\,/,All
send %clipboard%
return
#IfWinActive