loading...

Select an existing file, or create a new one to save data.

dlg_save(
  default = "untitled",
  title = "Save file as",
  filters = dlg_filters["All", ],
  ...,
  gui = .GUI
)

dlgSave(
  default = "untitled",
  title = "Save file as",
  filters = dlg_filters["All", ],
  ...,
  gui = .GUI
)

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

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

# S3 method for nativeGUI
dlg_save(
  default,
  title,
  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, but without predefined name).

title

A title to display on top of the dialog box.

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, since such kind of filter is defined differently there.

...

Pass further arguments to methods.

gui

The modified 'gui' object is returned invisibly. The chosen file, or an empty string (if the "cancel" button was clicked or confirmation was cancelled) is placed in gui$res (see example). For existing files, confirmation is always asked!

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.

Note

In case the file already exists, the user is prompted to confirm he wants to overwrite the existing file. If he clicks 'Cancel', then the return is an empty string. The 'RStudio' version of this dialog box currently ignores the filters = argument.

See also

Examples

if (FALSE) {
# Choose one R filename to save some R script into it
dlg_save(title = "Save R script to", filters = dlg_filters[c("R", "All"), ])$res
}