Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RStudio - render html content in viewer pane

Tags:

r

rstudio

I would like to display html content stored in my working directory in RStudio viewer pane. I have read this post and thought this should be possible.

However, local files are always rendered in external browser. Is there anything I am missing?

# This will render in Viewer pane
tempDir <- tempfile()
dir.create(tempDir)
htmlFile <- file.path(tempDir, "test.html")
writeLines('<html><body>Hi there</body></html>', htmlFile)
rstudio::viewer(htmlFile)

# This will render in external browser
writeLines('<html><body>Hi there</body></html>', 'test.html')
rstudio::viewer('test.html')
like image 295
Tomas Greif Avatar asked Apr 23 '15 19:04

Tomas Greif


1 Answers

According to the link you referenced: "Note that the Viewer pane can only be used for local web content. This content can either be static HTML files written to the session temporary directory (i.e. files with paths generated by the tempfile function) or a locally run web application."

In your second example, you are attempting to use the viewer on a file that is not in the session temporary directory.

like image 152
J. Win. Avatar answered Oct 13 '22 15:10

J. Win.