i am trying to export to powerpoint a flextable that has rows with pictures on it, but not displaying on the generated powerpoint.
However it works well on the R studio Viewer.
Do you have any idea where the problem is coming from plz?
Thanks in advance
library(kableExtra)
library(flextable)
library(officer)
doc <- read_pptx()
img.file <- file.path( R.home("doc"), "html", "logo.jpg" )
myft <- flextable( head(mtcars),
col_keys = c("am", "separator", "gear", "mpg", "drat", "qsec" ))
myft <- compose( myft, i = ~ qsec > 18, j = "qsec",
value = as_paragraph(as_image( src = img.file, width = .20, height = .15))
)
myft <- autofit(myft)
myft
doc <- add_slide(doc)
doc <- ph_with(doc, value = myft, location = ph_location_template(top = 2, width = 4, type = "body"))
print(doc, target = "./cars.pptx")
system2('cmd', args = c('/c', '"./cars.pptx"'))
This is not possible with PowerPoint, you can read documentation here: https://davidgohel.github.io/flextable/articles/display.html#limitation-for-powerpoint-1