to_ppt: Pass data to Powerpoint workbooks

Description Usage Arguments Details Note Author(s) Examples

Description

to_ppt allows you to pass R objects to an open pptWorkbook, and write it later with write_data. The pptWorkbook can be created by calling ppt_workbook. to_ppt will always format the output and add it to a new slide.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
to_ppt(x, wb, title = NULL, subtitle = NULL)

ppt_workbook(template = NULL, font = "Calibri", fontsize = 10L)

## S3 method for class 'data.frame'
to_ppt(x, wb, title = NULL, subtitle = NULL)

## S3 method for class 'FlexTable'
to_ppt(x, wb, title = NULL, subtitle = NULL)

## S3 method for class 'ggplot'
to_ppt(x, wb, title = NULL, subtitle = NULL)

## S3 method for class 'character'
to_ppt(x, wb, title = NULL, subtitle = NULL)

Arguments

x

A data.frame, string or plot

wb

A pptWorkbook.

title

Title to use for the new slide. Defaults to a single whitespace when title is NULL.

subtitle

The subtitle for the slide. When NULL (the default), to_ppt will use the 'title' attribute of the object, or a single whitespace if attr(x, 'title') returns NULL as well.

template

Optional: Specify a path if you would like to append slides to an existing powerpoint file (use it as a template). Default uses the template included in this package.

font

Default font (Replaces the ReporteRs-default-font option).

fontsize

Default fontsize (Replaces the ReporteRs-fontsize option).

Details

You can use this function to pass plot, data.frame (table and matrix will be coerced), and character objects to the workbook. Strings are assumed to be markdown.

Note

This function requires ReporteRs. The pptWorkbook object is a thin R6 wrapper around ReporteR's pptx, and allow us to use to_ppt in chained expressions, since the workbook is mutable.

Author(s)

Kristian D. Olsen

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
if (require(ReporteRs)) {
 wb <- ppt_workbook()
 df <- data.frame("String" = c("A", "B"), "Int" = c(1:2L), "Percent" = c(0.5, 0.75))

 # The workbook is mutable, so we don't have to assign result.
 to_ppt(df, wb, title = "Example data", subtitle = "")

 # Data is first argument, so we can use it with dplyr.
 # df %>% to_ppt(wb, title = "Example data", subtitle = "")

 # Save the data
 write_data(wb, "Example table.pptx")
}

itsdalmo/seamless documentation built on May 18, 2019, 7:11 a.m.