I want R to open a file that is created in my program. My code saves a log file to a variable called logFile using the following code.
logFile <- sprintf("../output/%s_%s_output%sof%s.log", str1, str2, str3, str4);
I tried to access the shell function by calling
shell('%s',logFile);
but I got an error that said
In shell("%s", toFile) : '%s' execution failed with error code 127
How can I get my program to open this file after it is finished writing to it?
How about?
browseURL('view.xlsx')
Are you looking for something like this? It works nicely, at least on my Windows box.
## An example temp file
ff <- paste0(tempfile(), ".txt")
write.table(head(mtcars), file=ff)
## Open the file with the program associated with its file extension
system2("open", ff)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With