我想在 RStudio 查看器 Pane 中显示存储在我的工作目录中的 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')
最佳答案
根据您引用的链接:“请注意,查看器 Pane 只能用于本地 Web 内容。该内容可以是写入 session 临时目录的静态 HTML 文件(即具有由 tempfile 函数生成的路径的文件)或本地运行的 Web 应用程序。”
在第二个示例中,您尝试对不在 session 临时目录中的文件使用查看器。
关于RStudio - 在查看器 Pane 中渲染 html 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29832288/