Reputation: 1288
I'm working with the htmlTable
function. While the table renders perfectly in the R studio viewer, I am unable to save, copy and paste, or screenshot it, such that it looks equally nice in the word document I am writing. I was wondering if there was a way for me to export or save the image, such that the table show up just as nice in the word document.
Here is an example table.
output <-
matrix(paste("Example", LETTERS[1:16]),
ncol=4, byrow = TRUE)
library(htmlTable)
htmlTable(output)
Upvotes: 1
Views: 3496
Reputation: 4906
It is ideal to import the table into your word processor in an editable form, as opposed to a screenshot or an image. In order to achieve this you need to:
htmlTable
to a new variable, then print that variable with the useViewer
argument.tb1 <- htmlTable(output)
print(tb1, useViewer = utils::browseURL)
As an aside, many people prefer importing and/or pasting HTML tables into Libre office as the layout and formatting is often more similar to the table rendered by the browser. After doing this in Libre office, you may wish to save the document in MS Word format.
Upvotes: 0
Reputation: 633
You can display your table as grid graphics using grid.table
function from gridExtra
library. And save it as image using ggsave
function from ggplot
library.
library(ggplot2)
library(gridExtra)
ggsave(grid.table(output), filename = "~DirectoryName/imageName.png")
Upvotes: 2