Title: | Object Oriented R -> PowerPoint |
---|---|
Description: | Provides a friendly, object oriented API for creating PowerPoint slide decks in R. |
Authors: | Matt Lehman [aut, cre] |
Maintainer: | Matt Lehman <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0.9001 |
Built: | 2024-10-31 16:34:14 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
).
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())
new_slide(layout, elements = list())
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. |
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_fn
function. Function in the officer::ph_location*
family
args
list. Arguments to pass to ph_location_fn
An S4 class to represent a PowerPoint presentation.
slides
list. List of 'R2PptxSlide' objects.
template_path
character. File path to the PowerPoint template used for this presentation.
An S4 class to represent a PowerPoint slide
layout
character. Name of the PowerPoint layout to use for this slide.
elements
list. List of 'R2PptxElement' objects.
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.
slides
list. 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.
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) <- value
template_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-method
: 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.
R2PptxPresentation
: Write a presentation to a '.pptx' file