Às 14:18 de 07/05/2026, Chris Ryan escreveu:
It had been about a year since I had worked in Windows, and apparently I
had gotten rusty. Forward slashes in path names, as in

read.csv("e:/path/to/datafileOnWindows.csv")

work just fine in R on Windows.

Sorry for the bother.

--Chris Ryan



Chris Ryan wrote:
I'm trying to generalize one of my scripts so that it will run on my
Linux Mint computer at home and my client's Windows 11 computer at work.
  I'm encountering trouble when setting file paths, conditional on which
computer the script is running on. It's the Windows backslash issue


______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Hello,

Probably off-topic but you can automate switching from "\\" to "/".
If run on Windows, normalizePath uses "\\".
Then, chartr it translates to "/".


path <- normalizePath("~")
chartr("\\", "/", path)


Hope this helps,

Rui Barradas

______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to