Hmm. I get exactly the same files and directories with "C:" and "C:/", except for the double slashes now. Previously the two calls to list.files gave exactly the same results. My current directory (getwd()) is not C:. I'm puzzled by your output.
-- David -----Original Message----- From: henrik.bengts...@gmail.com [mailto:henrik.bengts...@gmail.com] On Behalf Of Henrik Bengtsson Sent: Friday, January 23, 2009 8:36 PM To: David Reiner <dav...@rhotrading.com> Cc: r-help@r-project.org Subject: Re: [R] list.files changed in 2.7.0 And I'm not sure that list.files("C:", full.names=TRUE) returns correct pathnames, because it lists the files in the current directory (of C:), not the root of C:. There is a difference between C: and C:/, and you should get: list.files("C:", full.names=TRUE) [1] "C:aFile.txt" [2] "C:anotherFile.txt" list.files("C:/", full.names=TRUE) [1] "C:/Documents and Settings" [2] "C:/Program Files" Now we get: list.files("C:", full.names=TRUE) [1] "C:/aFile.txt" [2] "C:/anotherFile.txt" list.files("C:/", full.names=TRUE) [1] "C://Documents and Settings" [2] "C://Program Files" This causes pathnames <- list.files("C:", full.names=TRUE); file.exists(pathnames); to return all FALSE (not expected), whereas, pathnames <- list.files("C:"); file.exists(pathnames); returns all TRUE (expected). So, that extract slash seems to be the cause. My $.02 /Henrik On Fri, Jan 23, 2009 at 2:42 PM, <dav...@rhotrading.com> wrote: > I just noticed a change in the behavior of list.files from 2.6.1pat to > 2.7.0 > (I noticed it in 2.8.1 and traced back.) > > Previously, if the directory ended with a slash, and full.names=TRUE, > the names > returned had a single slash at the end of the directory, > but now there are two. I noticed since I was getting a list of certain > files and > then grepping in the list for a full name formed with a single slash. > (The double slash would be OK if I were opening the file since the OS > treats double > slash in a path the same as a single slash.) > > I searched through the release notes, etc., and couldn't find this > announced. > > Try >> list.files("C:", full.names=TRUE) >> list.files("C:/", full.names=TRUE) > > Is there any chance that this could be put back to the single slash > behavior? > > (This was on Windows XP.) > > Thanks, > David L. Reiner > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.