[Rd] [patch] Documentation for list.files when no matches found

Jonathan Carroll jono @ending from jc@rroll@com@@u
Mon Jan 7 03:03:26 CET 2019


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.



More information about the R-devel mailing list