f_open_file | R Documentation |
Opens a specified file using the default application associated with its file type. It automatically detects the operating system (Windows, Linux, or macOS) and uses the appropriate command to open the file.
f_open_file(filepath)
filepath |
A character string specifying the path to the file to be opened. The path can be absolute or relative. |
- On Windows, the f_open_file()
function uses shell.exec()
to open the file.
- On Linux, it uses xdg-open
via the system()
function.
- On macOS, it uses open
via the system()
function.
If an unsupported operating system is detected, the function will throw a message.
Does not return a value; it is called for its side effect of opening a file.
Sander H. van Delden plantmind@proton.me
[shell.exec()], [system()]
# NOTE: The use of "if(interactive())" prevents this example from running
# during automated CRAN checks. This is necessary because the example
# opens a file, a behavior restricted by CRAN policies for automated
# testing.You don't need to use "if(interactive())" in your own scripts.
if(interactive()) {
# Open a PDF file.
f_open_file("example.pdf")
# Open an image file.
f_open_file("image.png")
# Open a text file.
f_open_file("document.txt")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.