Jonathan Carroll
2019-Jan-07 02:03 UTC
[Rd] [patch] Documentation for list.files when no matches found
Apologies in advance if this is already known but a search of the r-devel archive did not immediately turn up any mentions. list.files() (and thus dir()) returns character(0) when no files are found in the requested path. This is useful and expected behaviour as length(dir()) can be tested for success. The Value documentation, however, indicates otherwise> A character vector containing the names of the files in the specified directories, or "" if there were no files.which would be less useful and does not match current behaviour. This appears to have been the case for the majority the lifetime of the software so I'm not sure it's terribly important, but for the sake of consistency, I propose the following simple patch. Kind regards, - Jonathan. --- a/src/library/base/man/list.files.Rd +++ b/src/library/base/man/list.files.Rd @@ -45,7 +45,7 @@ list.dirs(path = ".", full.names = TRUE, recursive = TRUE) } \value{ A character vector containing the names of the files in the - specified directories, or \code{""} if there were no files. If a + specified directories, or \code{character(0)} if there were no files. If a path does not exist or is not a directory or is unreadable it is skipped, with a warning.
Tomas Kalibera
2019-Jan-07 08:30 UTC
[Rd] [patch] Documentation for list.files when no matches found
Thanks for the report, fixed in documentation in R-devel. Best Tomas On 1/7/19 3:03 AM, Jonathan Carroll wrote:> Apologies in advance if this is already known but a search of the > r-devel archive did not immediately turn up any mentions. > > list.files() (and thus dir()) returns character(0) when no files are > found in the requested path. This is useful and expected behaviour as > length(dir()) can be tested for success. The Value documentation, > however, indicates otherwise > >> A character vector containing the names of the files in the specified directories, or "" if there were no files. > which would be less useful and does not match current behaviour. > > This appears to have been the case for the majority the lifetime of > the software so I'm not sure it's terribly important, but for the sake > of consistency, I propose the following simple patch. > > Kind regards, > > - Jonathan. > > --- a/src/library/base/man/list.files.Rd > +++ b/src/library/base/man/list.files.Rd > @@ -45,7 +45,7 @@ list.dirs(path = ".", full.names = TRUE, recursive = TRUE) > } > \value{ > A character vector containing the names of the files in the > - specified directories, or \code{""} if there were no files. If a > + specified directories, or \code{character(0)} if there were no files. If a > path does not exist or is not a directory or is unreadable it > is skipped, with a warning. > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Reasonably Related Threads
- RFC: (in-principle) native unquoting for standard evaluation
- Documentation error: wrong permissions given in FAQ
- RFC: (in-principle) native unquoting for standard evaluation
- RFC: (in-principle) native unquoting for standard evaluation
- make.unique rbind examples