shell.exec(file)
Inroduction
When writing a function, it is possible that you may want to ask the user where they want the data stored and if they want to open the file folder after the download has taken place. Well we can do this in R by invoking the shell.exec()
command where we use a variable like f_path
that is the path to the folder. We are going to go over a super simple example.
Function
Here is the function:
Here are the arguments.
file
- file, directory or URL to be opened.
Now let’s go over a simple example
Example
Here we go.
# Create a temporary file to store the zip file
<- utils::choose.dir()
f_path
# Open file folder?
if (.open_folder){
shell.exec(f_path)
}
If in our function creation we make a variable .open_folder
and set it equal to TRUE then the if statement will execute and shell.exec(f_path)
will open the specified path set by utils::choose.dir()
Voila!