如何将 htmlTable 从查看器导出到 R 中的 word 文档
How to export htmlTable from the viewer to a word document in R
我正在使用 htmlTable
函数。虽然 table 在 R studio 查看器中完美呈现,但我无法保存、复制和粘贴或截取它,因此它在我正在编写的 word 文档中看起来同样漂亮。我想知道是否有办法导出或保存图像,使 table 在 word 文档中显示得一样好。
这是一个例子table。
output <-
matrix(paste("Example", LETTERS[1:16]),
ncol=4, byrow = TRUE)
library(htmlTable)
htmlTable(output)
您可以使用 gridExtra
库中的 grid.table
函数将 table 显示为网格图形。并使用 ggplot
库中的 ggsave
函数将其保存为图像。
library(ggplot2)
library(gridExtra)
ggsave(grid.table(output), filename = "~DirectoryName/imageName.png")
我正在使用 htmlTable
函数。虽然 table 在 R studio 查看器中完美呈现,但我无法保存、复制和粘贴或截取它,因此它在我正在编写的 word 文档中看起来同样漂亮。我想知道是否有办法导出或保存图像,使 table 在 word 文档中显示得一样好。
这是一个例子table。
output <-
matrix(paste("Example", LETTERS[1:16]),
ncol=4, byrow = TRUE)
library(htmlTable)
htmlTable(output)
您可以使用 gridExtra
库中的 grid.table
函数将 table 显示为网格图形。并使用 ggplot
库中的 ggsave
函数将其保存为图像。
library(ggplot2)
library(gridExtra)
ggsave(grid.table(output), filename = "~DirectoryName/imageName.png")