rstudioapi package, you can request input from the user with various dialogs.
selectDirectory() APIs allow you to request the name of an existing or non-existing path on the system.
# request the path to an existing .csv file on disk <- rstudioapi::selectFile(caption = "Select CSV File", path filter = "CSV Files (*.csv)", existing = TRUE) # now, you could read the data using e.g. 'readr::read_csv()' <- readr::read_csv(path) data # request a file path (e.g. where you would like to save a new file) <- rstudioapi::selectFile(caption = "Save File", target label = "Save", existing = FALSE) # save data to the path provided by the user saveRDS(data, file = target)
rstudioapi::askForPassword() to request a password, or other credentials, from a user.
<- rstudioapi::askForPassword( token prompt = "Please provide your GitHub access token." )
rstudioapi::showDialog() to display an informative dialog to the user. This dialog is used to report some kind of status or information to the user; it does not request any input.
::showDialog(title = "Hello, world!", rstudioapimessage = "You're <b>awesome!</b>", url = "http://www.example.com")