Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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 ~/.

Note

The selectFile and selectDirectory functions were added in version 1.1.287 of RStudio.


rstudioapi

Safely Access the RStudio API

v0.13
MIT + file LICENSE
Authors
Kevin Ushey [aut, cre], JJ Allaire [aut], Hadley Wickham [aut], Gary Ritchie [aut], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.