Learn R Programming

flextable (version 0.9.10)

ph_with.flextable: Add a flextable into a PowerPoint slide

Description

Add a flextable in a PowerPoint document object produced by officer::read_pptx().

This function will create a native PowerPoint table from the flextable and the result can be eventually edited.

Usage

# S3 method for flextable
ph_with(x, value, location, ...)

Arguments

x

a pptx device

value

flextable object

location

a location for a placeholder. See officer::ph_location_type() for example.

...

unused arguments.

caption

Captions are not printed in PowerPoint slides.

While captions are useful for document formats like Word, RTF, HTML, or PDF, they aren't directly supported in PowerPoint slides. Unlike documents with a defined layout, PowerPoint slides lack a structured document flow. They don't function like HTML documents or paginated formats (RTF, Word, PDF). This makes it technically challenging to determine the ideal placement for a caption within a slide. Additionally, including a caption within the table itself isn't feasible.

Examples

Run this code
library(officer)

ft <- flextable(head(iris))

doc <- read_pptx()
doc <- add_slide(doc, "Title and Content", "Office Theme")
doc <- ph_with(doc, ft, location = ph_location_left())

fileout <- tempfile(fileext = ".pptx")
print(doc, target = fileout)

Run the code above in your browser using DataLab