Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Specify Width and Height of a Flextable

Tags:

r

r-flextable

I have a flextable that I would like to modify the length and width of to create a 3.5in x 3.5in table. I've tried looking around, but have so far found no easy way of manipulating table dimensions. Is anyone aware of a way to specify flextable length and height

Example code

library(flextable)

#read in data
data(mtcars)

#create flextable
ft<-flextable(mtcars[1:10,1:11])
ft

#save flextable
ft %>% save_as_image("../PATH/NAME.png")

like image 905
Jason Edelkind Avatar asked Nov 19 '25 15:11

Jason Edelkind


1 Answers

To save your flextable as a plot, you should use package 'ragg' and command plot() (or gen_grob()).

library(flextable)

# create flextable
ft <- flextable(mtcars[1:10, 1:11])
ft

# save flextable
ragg::agg_png(filename = "test.png",
              width = 3.5,
              height = 3.5,
              units = "in",
              res = 200)
plot(ft)
dev.off()

enter image description here

like image 175
David Gohel Avatar answered Nov 22 '25 03:11

David Gohel