RStudio - 在查看器窗格中呈现html内容

时间:2015-04-23 19:08:04

标签: r rstudio

我想在RStudio查看器窗格中显示存储在我的工作目录中的html内容。我读过this post并认为这应该是可能的。

但是,本地文件始终在外部浏览器中呈现。有什么我想念的吗?

# 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')

1 个答案:

答案 0 :(得分:1)

根据您引用的链接:&#34;请注意,“查看器”窗格只能用于本地Web内容。此内容可以是写入会话临时目录的静态HTML文件(即具有由tempfile函数生成的路径的文件)或本地运行的Web应用程序。&#34;

在第二个示例中,您试图在不在会话临时目录中的文件上使用查看器。

相关问题