Use a Windows file dialog to choose a list of zero or more files
interactively.
Usage
choose.files(default = "", caption = "Select files",
multi = TRUE, filters = Filters,
index = nrow(Filters))
Filters
Arguments
default
which filename to show initially
caption
the caption on the file selection dialog
multi
whether to allow multiple files to be selected
filters
a matrix of filename filters (see Details)
index
which row of filters to use by default
Details
Unlike file.choose, choose.files will always
attempt to return a character vector giving a list of files. If the
user cancels the dialog, then zero files are returned, whereas
file.choose would signal an error. choose.dir
chooses a directory.
Windows file dialog boxes include a list of ‘filters’, which allow
the file selection to be limited to files of specific types.
The filters argument to choose.files allows the list
of filters to be set. It should be an n by 2 character
matrix. The first column gives, for each filter, the description the
user will see, while the second column gives the mask(s) to select
those files. If more than one mask is used, separate them by
semicolons, with no spaces. The index argument chooses which
filter will be used initially.
Filters is a matrix giving the descriptions and masks for
the file types that R knows about. Print it to see typical formats
for filter specifications. The examples below show how particular
filters may be selected.
If you would like to display files in a particular directory,
give a fully qualified file mask (e.g., "c:\*.*")
in the default argument. If a directory is not given, the
dialog will start in the current directory the first time, and
remember the last directory used on subsequent invocations.
There is a buffer limit on the total length of the selected filenames:
it is large but this function is not intended to select thousands of
files, when the limit might be reached.
Value
A character vector giving zero or more file paths.
Note
This is only available on Windows.
See Also
file.choose, choose.dir.
Sys.glob or list.files to select multiple
files by pattern.
Examples
if (interactive())
choose.files(filters = Filters[c("zip", "All"),])
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(utils)
> png(filename="/home/ddbj/snapshot/RGM3/R_rel/result/utils/choose.files.Rd_%03d_medium.png", width=480, height=480)
> ### Name: choose.files
> ### Title: Choose a List of Files Interactively
> ### Aliases: choose.files Filters
> ### Keywords: file
>
> ### ** Examples
>
> # if (interactive())
> choose.files(filters = Filters[c("zip", "All"),])
Error: could not find function "choose.files"
Execution halted