Learn R Programming

svDialogs (version 1.1.0)

dlg_open: Modal dialog to select a file.

Description

Select an existing file, or create a new one.

Usage

dlg_open(
  default = "",
  title = if (multiple) "Select files" else "Select file",
  multiple = FALSE,
  filters = dlg_filters["All", ],
  ...,
  gui = .GUI
)

dlgOpen( default = "", title = if (multiple) "Select files" else "Select file", multiple = FALSE, filters = dlg_filters["All", ], ..., gui = .GUI )

dlg_filters

dlgFilters

# S3 method for gui dlg_open( default, title, multiple = FALSE, filters = dlg_filters["All", ], ..., gui = .GUI )

# S3 method for textCLI dlg_open( default, title, multiple = FALSE, filters = dlg_filters["All", ], ..., gui = .GUI )

# S3 method for nativeGUI dlg_open( default, title, multiple = FALSE, filters = dlg_filters["All", ], rstudio = getOption("svDialogs.rstudio", TRUE), ..., gui = .GUI )

Arguments

default

The default file to start with (use /dir/* or /dir/*.* to start in a given directory).

title

A title to display on top of the dialog box.

multiple

Is a multiple selection of files allowed?

filters

A specification of file filters as a nx2 matrix, or a character string with even number of items. First items is the label, second one is the filter. See dlg_filters for examples. This is currently ignored on MacOS and RStudio, since such kind of filter is defined differently there.

...

Pass further arguments to methods.

gui

The 'gui' object concerned by this dialog box.

rstudio

Logical. Should 'RStudio' dialog boxes automatically be used if available? If FALSE, force using OS dialog boxes, but only in 'RStudio Desktop' (ignored in 'RStudio Server'). Can be changed globally with options(svDialogs.rstudio = TRUE|FALSE). TRUE by default.

Value

The modified 'gui' object is returned invisibly. The chosen file(s), or an empty string if the "cancel" button was clicked is found in gui$res (see example).

Format

An object of class matrix (inherits from array) with 22 rows and 2 columns.

An object of class matrix (inherits from array) with 22 rows and 2 columns.

See Also

dlg_save(), dlg_dir()

Examples

Run this code
# NOT RUN {
# Choose one R file
dlg_open(title = "Select one R file", filters = dlg_filters[c("R", "All"), ])$res
# Choose several files
dlg_open(multiple = TRUE)$res
# }

Run the code above in your browser using DataLab