[Rd] Proposed change in file.exists() to tolerate Windows

Paul Johnson pauljohn32 at gmail.com
Thu Aug 27 16:02:17 CEST 2015


I'm writing to ask if R Core would make file.exists more Windows
tolerant when the argument has a trailing slash. This has been
discussed by users a few times here, I know it is not a new topic. But
it is not a solved problem, yet. I acknowledge that CRAN packages
exist which fix this by replacing file.exists(), but it seems more
elegant to me to fix the problem in R itself.

R Core goes to great extremes to accommodate Windows users and the
refusal to make file.exists() work in a cross-platform way is
incongruous.

I often do have slashes on the end of directory names being tested.
Now that I understand the meaning of ?file.exists,  I need to wrap the
name being checked in a slash-deleter

## delete trailing slashes
dts <- function(name) gsub("/$", "", name)
if(!file.exists(dts(any_name))) { ...

Can't you make file.exists do this invisibly? Maybe the argument could
be filtered through normalizePath() instead.

If not, would you please consider putting a workaround like mine into
the file.exists documentation so Windows users can see how easy this
is to avoid?

Respectfully yours,

pj

-- 
Paul E. Johnson
Professor, Political Science        Director
1541 Lilac Lane, Room 504      Center for Research Methods
University of Kansas                 University of Kansas
http://pj.freefaculty.org              http://crmda.ku.edu



More information about the R-devel mailing list