我想在 RStudio 查看器窗格中显示存储在我的工作目录中的 html 内容。我读过了这个帖子 https://support.rstudio.com/hc/en-us/articles/202133558-Extending-RStudio-with-the-Viewer-Pane并认为这应该是可能的。
但是,本地文件始终在外部浏览器中呈现。我有什么遗漏的吗?
# 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')
根据您引用的链接:“请注意,查看器窗格只能用于本地 Web 内容。该内容可以是写入会话临时目录的静态 HTML 文件(即具有 tempfile 函数生成的路径的文件),也可以是本地运行网络应用程序。”
在第二个示例中,您尝试对不在会话临时目录中的文件使用查看器。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)