How to open a local html file from R in an operating system independent way?
You might find my open.file.in.OS
function useful, sources can be found here.
A short summary about what this function does:
- Check platform
- Based on platform, call:
shell.exec
on Windowsopen
withsystem
on Mac- and
xdg-open
withsystem
on other Unix-like operating system
- Uses
shQuote
on the privided file
Update: See now the openFileInOS
in the pander
package.
library(pander)
openFileInOS("d:/del/dt/a.html")
References: this function is a forked version of David Hajage's convert
function can be found here.
I just wanted to pull the answer given by @daroczig out of the comments and into an answer. If @darcozig wants to post this as a separate answer, I'll delete this copy.
openHTML <- function(x) browseURL(paste0('file://', file.path(getwd(), x)))