Looking for tips to save a table as an image with the quality seen in the RStudio Viewer. I've tried save_kable
and as_image
but both resulted in serious drops in quality.
Any other recommendations?
Code for reference:
library(htmlTable)
library(xtable)
library(kableExtra)
data(tli)
htmlTable(xtable(tli[1:10,),rnames=FALSE)%>%save_kable('table.png')`
You can also specify the width and the height in pixels. In R GUI you will need to go to File → Save as and select the type of file you prefer. If you select Jpeg , you can also specify the quality of the resulting image. The last option is copying the image to the Clipboard.
The best way to convert table to image in Word is by saving it as a Picture. First, select the table and right-click on the table. Copy and paste it into a new document by using the Paste Special: Picture option. Finally, right-click on the pasted image and click on Save As Picture.
If you're running R through Rstudio, then the easiest way to save your image is to click on the “Export” button in the Plot panel (i.e., the area in Rstudio where all the plots have been appearing). When you do that you'll see a menu that contains the options “Save Plot as PDF” and “Save Plot as Image”.
Click the chart that you want to save as a picture. Choose Copy from the ribbon, or press CTRL+C on your keyboard . Switch to the application you want to copy the chart to. If you're saving as a separate image file open your favorite graphics editor, such as Microsoft Paint.
The save_kable
function has a ...
argument which passes variables to webshot::webshot
.
From the webshot README, you can generate higher quality screenshots with the zoom
option, e.g.,
library(knitr)
library(kableExtra)
library(magrittr)
kable(iris[1:10,]) %>%
kable_styling() %>%
save_kable(file = "table_1.png")
kable(iris[1:10,]) %>%
kable_styling() %>%
save_kable(file = "table_2.png",
zoom = 1.5)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With