【发布时间】:2015-04-23 19:08:04
【问题描述】:
我想在 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')
【问题讨论】:
-
来自该链接:“此内容可以是写入会话临时目录的静态 HTML 文件(即具有由 tempfile 函数生成的路径的文件)或本地运行的 Web 应用程序。”您的第二个示例不尝试查看由
tempfile()函数生成的文件。 -
@MrFlick 是的,你是对的。你能把你的评论变成答案吗?