Learn R Programming

rstudioapi (version 0.14)

file-dialogs: Select a file / folder

Description

Prompt the user for the path to a file or folder, using the system file dialogs with RStudio Desktop, and RStudio's own dialogs with RStudio Server.

Usage

selectFile(
  caption = "Select File",
  label = "Select",
  path = getActiveProject(),
  filter = "All Files (*)",
  existing = TRUE
)

selectDirectory( caption = "Select Directory", label = "Select", path = getActiveProject() )

Arguments

caption

The window title.

label

The label to use for the 'Accept' / 'OK' button.

path

The initial working directory, from which the file dialog should begin browsing. Defaults to the current RStudio project directory.

filter

A glob filter, to be used when attempting to open a file with a particular extension. For example, to scope the dialog to R files, one could use R Files (*.R) here.

existing

Boolean; should the file dialog limit itself to existing files on the filesystem, or allow the user to select the path to a new file?

Details

When the selected file resolves within the user's home directory, RStudio will return an aliased path -- that is, prefixed with ~/.