Package 'r2pptx'

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

Help Index


Add R2Ppptx slide

Description

Add an 'R2PptxSlide' object to something else compatible.

Usage

## S4 method for signature 'R2Pptx,R2PptxSlide'
e1 + e2

Arguments

e1

An object that a slide can be added to, such as an 'R2PptxPresentation', 'R2PptxSlide', or 'R2PptxSlideList'.

e2

'R2PptxSlide' object

Value

If e1 is an object of class R2PptxPresentation then returns an object of class R2PptxPresentation. Otherwise returns an object of class R2PptxSlideList


Add element to slide

Description

Add an R2PptxElement object to an R2PptxSlide object.

Usage

## S4 method for signature 'R2PptxSlide,R2PptxElement'
e1 + e2

Arguments

e1

R2PptxSlide object

e2

R2PptxElement object

Value

An object of class R2PptxSlide, which is e1 with an additional element e2


Add slide to slidelist

Description

Add slide to slidelist

Usage

## S4 method for signature 'R2PptxSlide,R2PptxSlideList'
e1 + e2

Arguments

e1

PR2PptxSlide object

e2

R2PptxSlideList object

Value

An object of class R2PptxSlideList which is the R2PptxSlideList list e1 with an additional slide which is e2.


Add slidelist to slidelist

Description

Add slidelist to slidelist

Usage

## S4 method for signature 'R2PptxSlideList,R2PptxSlideList'
e1 + e2

Arguments

e1

R2PptxSlideList object

e2

R2PptxSlideList object

Value

An object of class R2PptxSlideList which is e1 with additional slides (all the slides in e2).


Gets layout properties

Description

A thin wrapper around officer::plot_layout_properties() to get layouts properties for R2PpptxPresentation objects.

Usage

get_layout_properties(x, layout)

Arguments

x

R2PpptxPresentation object

layout

character. Name of the layout to see properties for.

Value

An object of class data.frame with fields for placeholder attributes and one row per placeholder element.


Get layouts

Description

A thin wrapper around officer::layout_summary() to get layouts for R2PpptxPresentation objects.

Usage

get_layouts(x)

Arguments

x

R2PpptxPresentation object

Value

An object of class data.frame with fields for the layout name and the name of the slide theme (master).


method to get slides

Description

method to get slides

Usage

## S4 method for signature 'R2PptxSlideList'
get_slides(x)

Arguments

x

R2PptxSlideList object

Value

List, a list of R2PptxSlide objects.


Get slide length

Description

Returns the number of elements in a slide

Usage

## S4 method for signature 'R2PptxSlide'
length(x)

## S4 method for signature 'R2PptxPresentation'
length(x)

Arguments

x

'R2PptxSlide' object

Value

Integer, number of elements in the R2PptxSlide object

Integer, the number of slides in the presentation.


New Element

Description

Make a new 'R2PptxElement'. Element represent text, a flextable, an image, a ggplot2, etc to add to a slide.

Usage

new_element(key, value)

Arguments

key

character. Name of the placeholder label for this element.

value

object. Object to put into a PowerPoint slide, eg text or a plot.

Value

An object of class R2PptxElement representing something to put on a slide.


New Element

Description

Make a new 'R2PptxElement'. Element represent text, a flextable, an image, a ggplot2, etc to add to a slide.

Usage

## S4 method for signature 'character'
new_element(key, value)

Arguments

key

character. Name of the placeholder label for this element.

value

object. Object to put into a PowerPoint slide, eg text or a plot.

Value

An object of class R2PptxElement representing something to put on a slide.


New Element

Description

Make a new 'R2PptxElement'. Element represent text, a flextable, an image, a ggplot2, etc to add to a slide.

Usage

## S4 method for signature 'R2PptxLocation'
new_element(key, value)

Arguments

key

'R2PptxLocation' object created with new_location()

value

object. Object to put into a PowerPoint slide, eg text or a plot.

Value

An object of class R2PptxElement representing something to put on a slide.


New Location

Description

New Location

Usage

new_location(ph_location_fn, ...)

Arguments

ph_location_fn

function. Function in the officer::ph_location* family

...

args to pass to ph_location_fn

Value

An object of class R2PptxLocation representing the location to place an R2PptxElement.

See Also

ph_location

Examples

# 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)

New Presentation

Description

Make a new 'R2PptxPresentation'. Presentations represent PowerPoint decks.

Usage

new_presentation(
  template_path = getOption("default_pptx_template"),
  slides = list()
)

Arguments

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.

Value

An object of class R2PptxPresentation representing a future PowerPoint presentation.


New slide

Description

Make a 'R2PptxSlide' object representing a PowerPoint slide.

Usage

new_slide(layout, elements = list())

Arguments

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.

Value

An object of class R2PptxSlide representing a future PowerPoint slide.


New slide list

Description

Make a R2PptxSlideList object representing a list of PowerPoint slides

Usage

new_slidelist(slides = list())

Arguments

slides

list. List of R2PptxSlide objects to initialize the list with. Defaults to empty list.

Value

An object of class R2PptxSlideList representing a list of R2pptxSlide object.


Plot layout

Description

A thin wrapper around officer::plot_layout_properties() to plot layouts for R2PpptxPresentation objects.

Usage

plot_layout(x, layout)

Arguments

x

R2PpptxPresentation object

layout

character. Name of the layout to see properties for.

Value

No return value, called for side effects


Element

Description

An S4 An class to represent text, a flextable, an image, a ggplot2, etc we add to a slide.


Location

Description

A Location is used to place an element on a slide.

Slots

ph_location_fn

function. Function in the officer::ph_location* family

args

list. Arguments to pass to ph_location_fn


Presentation

Description

An S4 class to represent a PowerPoint presentation.

Slots

slides

list. List of 'R2PptxSlide' objects.

template_path

character. File path to the PowerPoint template used for this presentation.


Slide

Description

An S4 class to represent a PowerPoint slide

Slots

layout

character. Name of the PowerPoint layout to use for this slide.

elements

list. List of 'R2PptxElement' objects.


Slide list

Description

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.

Slots

slides

list. A list of R2PptxSlide objects


Get template path

Description

Get template path

Usage

template_path(x)

## S4 method for signature 'R2PptxPresentation'
template_path(x)

Arguments

x

object to get the template path for.

Value

Character, the file path this R2PptxPresentation points to.

Methods (by class)

  • R2PptxPresentation: Get the template path of an R2PptxPresentation object.


Set template path

Description

Set template path

Usage

template_path(x) <- value

## S4 replacement method for signature 'R2PptxPresentation'
template_path(x) <- value

Arguments

x

object to set the template path of.

value

character. File path of the new template

Value

The R2PptxPresentation object x with the changed template path.

Functions

  • template_path<-,R2PptxPresentation-method: Set the template path of an R2PptxPresentation object.


Write pptx

Description

Write an object to a '.pptx' file.

Usage

write_pptx(x, path)

## S4 method for signature 'R2PptxPresentation'
write_pptx(x, path)

Arguments

x

object

path

character. File path to write to.

Value

Returns the R2PptxPresentation object given to the function.

Methods (by class)

  • R2PptxPresentation: Write a presentation to a '.pptx' file