将RStudio的View()输出保存为html

ins*_*ven 3 r rstudio

是否可以将我View()在RStudio中使用命令时看到的页面保存为某些数据作为html文件?

Set*_*eth 5

也许您的数据看起来像mtcars数据

data(mtcars)
View(mtcars)

library(xtable)
Run Code Online (Sandbox Code Playgroud)

sink命令将输出发送到文件

sink('somehtmlfile.html')
print(xtable(mtcars),type='html')
Run Code Online (Sandbox Code Playgroud)

然后将事情恢复正常

sink()
Run Code Online (Sandbox Code Playgroud)

现在在浏览器中打开somehtmlfile.html