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

Save View() output of RStudio as html

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

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

data(mtcars)
View(mtcars)

library(xtable)

sink 命令将输出发送到文件

sink('somehtmlfile.html')
print(xtable(mtcars),type='html')

然后 return 事情恢复正常

sink()

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