ImportDlg
displays the FileOpen-Dialog for picking a file interactively. When done backslashes in the path are replaced by slashes and the result is being copied into the clipboard, from where it can easily be pasted in any code editor.ImportDlg(fmt = 1)
ImportDlg()
invisibly returns the path of the chosen file in the defined format.
The result is additionally being copied to the clipboard.file.choose
# choose a file
fn <- ImportDlg()
print(gettextf("You chose the file: %s ", fn))
# the path and filename can as well be nested in a command,
# done here to build a read.table command that can be well inserted into the code:
ImportDlg(fmt="d.%fname% <- read.table(file = \"%path%\%fname%.%fxt%\",
header = TRUE, sep = \";\", na.strings = c(\"NA\",\"NULL\"), strip.white = TRUE)")
# go to your editor and paste...
Run the code above in your browser using DataLab