I want to make a demo tool to load a file up for R users that is independent of OS. On a Windows system I use shell.exec
but know this isn't the same for mac and Linux. I believe they use system
but have no idea how as I never have had the need to use anything but shell.exec
. Here's the function thus far:
open_file <- function(file.name) {
if (Sys.info()["sysname"] == "Windows") {
shell.exec(file.name)
} else {
#insert linux and mac equiv here (I think they're the same)
}
}
What could I put into the inset Linux and Mac OS X... part to make it work on these machines as well?
EDIT: in my function shell.exec opens a file that happens to be docx and it uses MS Word, but I'm wanting this to be generic to open txt csv xlsx files as well.