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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Jonathan Carroll-2
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.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

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

Tomas Kalibera
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.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel