Opens a file using the system's default application in a cross-platform manner. Works on Windows, macOS, and Linux.
open_file(path)Invisible NULL. The function is called for its side effect of opening a file.
This function detects the operating system and uses the appropriate command to open the file:
Windows: Uses shell.exec()
macOS: Uses system2("open", ...)
Linux: Uses system2("xdg-open", ...)
if (FALSE) { # \dontrun{
# Open a PDF file
open_file("path/to/document.pdf")
# Open an Excel file
open_file("path/to/spreadsheet.xlsx")
# Open a PNG image
open_file("path/to/image.png")
} # }