gpt4 book ai didi

RStudio - 在查看器 Pane 中渲染 html 内容

转载 作者:行者123 更新时间:2023-12-01 22:41:07 25 4
gpt4 key购买 nike

我想在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com