在RStudio查看器中查看markdown生成的html

Mac*_*iej 10 r r-markdown

我想看看在RStudio查看器中html生成的文件,但是markdownRStudiorstudio::viewer('test.html')外面的浏览器中打开我的文件.你能告诉我怎样才能做到这一点?

这个例子有效但我不知道为什么我的例子不能以这种方式工作.

test.html 文件它是我们选择新文件时得到的一个简单示例 - > R Markdown.

编辑(根据RomanLuštrik评论)

library(knitr)
library(markdown)
f <- system.file("examples", "knitr-minimal.Rmd", package = "knitr")
knit(f)
markdownToHTML('knitr-minimal.md',output='knitr-minimal.html')
rstudio::viewer('knitr-minimal.html')
Run Code Online (Sandbox Code Playgroud)

Dom*_*ois 7

使用密钥tempfile(),作为解释在这里。只要html文件位于会话temp dir之外,Rstudio就不会显示它。

另一方面,这将起作用:

temp.f <- tempfile()
cat("Hello", file = temp.f)
rstudio::viewer(temp.f)
Run Code Online (Sandbox Code Playgroud)

编辑

正如@Sebastian Palma在评论中指出的那样,“ rstudio”包已被“ rstudioapi”替换,因此第三行现在应为:

rstudioapi::viewer(temp.f)
Run Code Online (Sandbox Code Playgroud)


小智 6

在我的RStudio版本(0.98.994)上,单击"编织HTML"按钮右侧的小向下箭头,可以选择"在窗格中查看"和"在窗口中查看".选择第一个而不是第二个为我修复它.