[R] how to put a single backslash into a string, to make file paths usable on windows

Richard O'Keefe r@oknz @end|ng |rom gm@||@com
Fri May 8 04:30:36 CEST 2026


This isn't an R thing.  The Windows system calls that accept file names
accept both kinds of slash indifferently.  I've seen it said that this goes
back to MS-DOS 2, but certainly it's all NT versions.  If you need to link
C and/or Fortran with R, you can safely use / in file name strings in those
languages too.

On Fri, 8 May 2026 at 01:18, Chris Ryan <cwr using agencystatistical.com> wrote:

> 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
> >
>
> ______________________________________________
> R-help using r-project.org 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list