| Title: | Object Oriented R -> PowerPoint |
|---|---|
| Description: | Provides a friendly, object oriented API for creating PowerPoint slide decks in R. |
| Authors: | Matt Lehman [aut, cre], Ari Lewenstein [ctb] |
| Maintainer: | Matt Lehman <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0.9003 |
| Built: | 2026-05-26 21:57:04 UTC |
| Source: | https://github.com/mattle24/r2pptx |
Add an 'R2PptxSlide' object to something else compatible.
## S4 method for signature 'R2Pptx,R2PptxSlide' e1 + e2## S4 method for signature 'R2Pptx,R2PptxSlide' e1 + e2
e1 |
An object that a slide can be added to, such as an 'R2PptxPresentation', 'R2PptxSlide', or 'R2PptxSlideList'. |
e2 |
'R2PptxSlide' object |
If e1 is an object of class R2PptxPresentation then
returns an object of class R2PptxPresentation. Otherwise returns an
object of class R2PptxSlideList
Add an R2PptxElement object to an R2PptxSlide object.
## S4 method for signature 'R2PptxSlide,R2PptxElement' e1 + e2## S4 method for signature 'R2PptxSlide,R2PptxElement' e1 + e2
e1 |
|
e2 |
|
An object of class R2PptxSlide, which is e1 with an
additional element e2
Add slide to slidelist
## S4 method for signature 'R2PptxSlide,R2PptxSlideList' e1 + e2## S4 method for signature 'R2PptxSlide,R2PptxSlideList' e1 + e2
e1 |
|
e2 |
|
An object of class R2PptxSlideList which is the
R2PptxSlideList list e1 with an additional slide which is
e2.
Add slidelist to slidelist
## S4 method for signature 'R2PptxSlideList,R2PptxSlideList' e1 + e2## S4 method for signature 'R2PptxSlideList,R2PptxSlideList' e1 + e2
e1 |
|
e2 |
|
An object of class R2PptxSlideList which is e1 with
additional slides (all the slides in e2).
Gets all the layout properties for all the layouts in a presentation
get_all_layout_properties(x)get_all_layout_properties(x)
x |
|
An object of class data.frame with fields for placeholder
attributes and one row per placeholder element per layout.
A thin wrapper around officer::plot_layout_properties() to get layouts
properties for R2PpptxPresentation objects.
get_layout_properties(x, layout)get_layout_properties(x, layout)
x |
|
layout |
character. Name of the layout to see properties for. |
An object of class data.frame with fields for placeholder
attributes and one row per placeholder element.
A thin wrapper around officer::layout_summary() to get layouts for
R2PpptxPresentation objects.
get_layouts(x)get_layouts(x)
x |
|
An object of class data.frame with fields for the layout name
and the name of the slide theme (master).
method to get slides
## S4 method for signature 'R2PptxSlideList' get_slides(x)## S4 method for signature 'R2PptxSlideList' get_slides(x)
x |
|
List, a list of R2PptxSlide objects.
Returns the number of elements in a slide
## S4 method for signature 'R2PptxSlide' length(x) ## S4 method for signature 'R2PptxPresentation' length(x)## S4 method for signature 'R2PptxSlide' length(x) ## S4 method for signature 'R2PptxPresentation' length(x)
x |
'R2PptxSlide' object |
Integer, number of elements in the R2PptxSlide object
Integer, the number of slides in the presentation.
Make a new 'R2PptxElement'. Element represent text, a flextable, an image, a ggplot2, etc to add to a slide.
new_element(key, value)new_element(key, value)
key |
character. Name of the placeholder label for this element. |
value |
object. Object to put into a PowerPoint slide, eg text or a plot. |
An object of class R2PptxElement representing something to put
on a slide.
Make a new 'R2PptxElement'. Element represent text, a flextable, an image, a ggplot2, etc to add to a slide.
## S4 method for signature 'character' new_element(key, value)## S4 method for signature 'character' new_element(key, value)
key |
character. Name of the placeholder label for this element. |
value |
object. Object to put into a PowerPoint slide, eg text or a plot. |
An object of class R2PptxElement representing something to put
on a slide.
Make a new 'R2PptxElement'. Element represent text, a flextable, an image, a ggplot2, etc to add to a slide.
## S4 method for signature 'R2PptxLocation' new_element(key, value)## S4 method for signature 'R2PptxLocation' new_element(key, value)
key |
'R2PptxLocation' object created with |
value |
object. Object to put into a PowerPoint slide, eg text or a plot. |
An object of class R2PptxElement representing something to put
on a slide.
New Location
new_location(ph_location_fn, ...)new_location(ph_location_fn, ...)
ph_location_fn |
function. Function in the |
... |
args to pass to |
An object of class R2PptxLocation representing the location to
place an R2PptxElement.
# create an element with some text offset 2 from the left and 2 from the top # of the slide element_location <- new_location(officer::ph_location, left = 2, top = 2) element <- new_element( key = element_location, value = "Some text" ) presentation <- new_presentation() + new_slide("Title Slide", elements = list(element)) path <- tempfile(fileext = ".pptx") write_pptx(presentation, path) if (interactive()) browseURL(path)# create an element with some text offset 2 from the left and 2 from the top # of the slide element_location <- new_location(officer::ph_location, left = 2, top = 2) element <- new_element( key = element_location, value = "Some text" ) presentation <- new_presentation() + new_slide("Title Slide", elements = list(element)) path <- tempfile(fileext = ".pptx") write_pptx(presentation, path) if (interactive()) browseURL(path)
Make a new 'R2PptxPresentation'. Presentations represent PowerPoint decks.
new_presentation( template_path = getOption("default_pptx_template"), slides = list() )new_presentation( template_path = getOption("default_pptx_template"), slides = list() )
template_path |
character. Path of the file that has the PowerPoint template to use. Defaults to path set in 'options("default_pptx_template")' |
slides |
list. Optional. List of slides to initiate the presentation with. |
An object of class R2PptxPresentation representing a future
PowerPoint presentation.
Make a 'R2PptxSlide' object representing a PowerPoint slide.
new_slide(layout, elements = list(), notes = NULL)new_slide(layout, elements = list(), notes = NULL)
layout |
character. Name of the PowerPoint layout to use for this slide. |
elements |
list. List of 'R2PptxElements' to initialize the slide with. Defaults to empty list. |
notes |
character. Optional speaker notes for the slide. A single string; ‘NULL' (the default) leaves the slide’s notes empty. Speaker notes round-trip through Google Drive's pptx → Slides conversion, so notes set here will appear in the Google Slides notes panel after upload. |
An object of class R2PptxSlide representing a future
PowerPoint slide.
Make a R2PptxSlideList object representing a list of PowerPoint slides
new_slidelist(slides = list())new_slidelist(slides = list())
slides |
list. List of |
An object of class R2PptxSlideList representing a list of
R2pptxSlide object.
A thin wrapper around officer::plot_layout_properties() to plot
layouts for R2PpptxPresentation objects.
plot_layout(x, layout)plot_layout(x, layout)
x |
|
layout |
character. Name of the layout to see properties for. |
No return value, called for side effects
An S4 An class to represent text, a flextable, an image, a ggplot2, etc we add to a slide.
A Location is used to place an element on a slide.
ph_location_fnfunction. Function in the officer::ph_location* family
argslist. Arguments to pass to ph_location_fn
An S4 class to represent a PowerPoint presentation.
slideslist. List of 'R2PptxSlide' objects.
template_pathcharacter. File path to the PowerPoint template used for this presentation.
An S4 class to represent a PowerPoint slide
layoutcharacter. Name of the PowerPoint layout to use for this slide.
elementslist. List of 'R2PptxElement' objects.
notescharacter. Speaker notes for the slide. Length 0 means no notes; otherwise a length-1 character.
R2PptxSlideList is an S4 class to contain groups of R2PptxSlide
objects that are not part of a presentation. It is meant to be used to create
lists of slides and then be able to add the list easily to a presentation.
slideslist. A list of R2PptxSlide objects
Get template path
template_path(x) ## S4 method for signature 'R2PptxPresentation' template_path(x)template_path(x) ## S4 method for signature 'R2PptxPresentation' template_path(x)
x |
object to get the template path for. |
Character, the file path this R2PptxPresentation points to.
template_path(R2PptxPresentation): Get the template path of an
R2PptxPresentation object.
Set template path
template_path(x) <- value ## S4 replacement method for signature 'R2PptxPresentation' template_path(x) <- valuetemplate_path(x) <- value ## S4 replacement method for signature 'R2PptxPresentation' template_path(x) <- value
x |
object to set the template path of. |
value |
character. File path of the new template |
The R2PptxPresentation object x with the changed
template path.
template_path(R2PptxPresentation) <- value: Set the template path of an R2PptxPresentation
object.
Write an object to a '.pptx' file.
write_pptx(x, path) ## S4 method for signature 'R2PptxPresentation' write_pptx(x, path)write_pptx(x, path) ## S4 method for signature 'R2PptxPresentation' write_pptx(x, path)
x |
object |
path |
character. File path to write to. |
Returns the R2PptxPresentation object given to the function.
write_pptx(R2PptxPresentation): Write a presentation to a '.pptx' file