add2c_y2: Add 2 charts to PowerPoint slide

View source: R/add2c_y2.R

add2c_y2R Documentation

Add 2 charts to PowerPoint slide

Description

This function adds 2 charts/tables/other objects to a PowerPoint slide. The charts are automatically added to the last slide of the PP object in R. For this function to work, you need a powerpoint object saved into R called "doc"

Usage

add2c_y2(name, position, label_first_only = FALSE)

Arguments

name

The name of the chart/table/other object to be added to a new PowerPoint slide.

position

Position options: "top"; "bottom"; "left"; "right". The chart layout can either be top-bottom OR left-right.

label_first_only

DEFAULT = FALSE; Set to TRUE if for a series of left-to-right charts where only the first chart has axis labels. Changing this setting to T in this case will slightly adjut positioning for equally sized graphs

Examples

## Not run: 
# First create a chart that you can add into a powerpoint object
frequencies <- mtcars %>%
  y2clerk::freqs(carb) %>%
  orderlabel::order_label(inherent_order_label = T)
color_settings <- list('blue')
text_settings<- list('result' = officer::fp_text(font.size = 20))
chart_name <- y2artisan::ms_single_y2()

# Then before adding additional slides, charts, or tables onto a powerpoint,
# you must first read a PowerPoint into R
doc <- read_pptx('~/Y2 Analytics Dropbox/Y2 Analytics Team Folder/Projects/
Qualtrics/2021 Template and Resources/Template for mscharts.pptx')

# Now start adding in your charts
doc <- add1s_y2()
doc <- add2c_y2(chart_name, 'left')
doc <- add2c_y2(chart_name, 'right')

doc <- add1s_y2()
doc <- add2c_y2(chart_name, 'top')
doc <- add2c_y2(chart_name, 'bottom')

print(doc, '~/Desktop/test.pptx')

## End(Not run)

nick-moffitt/y2artisan documentation built on July 30, 2023, 5:40 p.m.