ph_with

0th

Percentile

add object into a new shape

add object into a new shape in a slide.

Usage
ph_with(x, value, ...)

# S3 method for character ph_with(x, value, location, ...)

# S3 method for numeric ph_with(x, value, location, format_fun = format, ...)

# S3 method for factor ph_with(x, value, location, ...)

# S3 method for logical ph_with(x, value, location, format_fun = format, ...)

# S3 method for block_list ph_with(x, value, location, ...)

# S3 method for unordered_list ph_with(x, value, location, ...)

# S3 method for data.frame ph_with(x, value, location, header = TRUE, first_row = TRUE, first_column = FALSE, last_row = FALSE, last_column = FALSE, ...)

# S3 method for gg ph_with(x, value, location, ...)

# S3 method for external_img ph_with(x, value, location, use_loc_size = TRUE, ...)

# S3 method for xml_document ph_with(x, value, location, ...)

Arguments
x

a pptx device

value

object to add as a new shape.

...

Arguments to be passed to methods

location

a placeholder location object. This is a convenient argument that can replace usage of arguments type and index. See section see also.

format_fun

format function for non character vectors

header

display header if TRUE

first_row, last_row, first_column, last_column

logical for PowerPoint table options

use_loc_size

if set to FALSE, external_img width and height will be used.

with character

When value is a character vector, each value will be added as a paragraph.

with vector

When value is a vector, the values will be first formatted and then add as text, each value will be added as a paragraph.

with block_list

When value is a block_list object, each value will be added as a paragraph.

with unordered_list

When value is a unordered_list object, each value will be added as a paragraph.

with data.frame

When value is a data.frame, a simple table is added, use package flextable instead for more advanced formattings.

with a ggplot object

When value is a ggplot object, a raster plot is produced and added, use package rvg instead for more advanced graphical features.

with a external_img object

When value is a external_img object, image will be copied into the PowerPoint presentation. The width and height specified in call to external_img will be ignored, their values will be those of the location, unless use_loc_size is set to FALSE.

with xml_document

When value is an xml_document object, its content will be added as a new shape in the current slide. This function is to be used to add custom openxml code.

See Also

ph_location_type, ph_location, ph_location_label, ph_location_left, ph_location_right, ph_location_fullsize

Aliases
  • ph_with
  • ph_with.character
  • ph_with.numeric
  • ph_with.factor
  • ph_with.logical
  • ph_with.block_list
  • ph_with.unordered_list
  • ph_with.data.frame
  • ph_with.gg
  • ph_with.external_img
  • ph_with.xml_document
Examples
# NOT RUN {
library(magrittr)

fileout <- tempfile(fileext = ".pptx")
doc <- read_pptx()
doc <- add_slide(doc, layout = "Two Content",
  master = "Office Theme")
doc <- ph_with(x = doc, value = c("Un titre", "Deux titre"),
               location = ph_location_left() )
doc <- ph_with(x = doc, value = iris[1:4, 3:5],
               location = ph_location_right() )

if( require("ggplot2") ){
  doc <- add_slide(doc, layout = "Title and Content",
    master = "Office Theme")
  gg_plot <- ggplot(data = iris ) +
    geom_point(mapping = aes(Sepal.Length, Petal.Length),
      size = 3) +
    theme_minimal()
  doc <- ph_with(x = doc, value = gg_plot,
                 location = ph_location_fullsize() )
}

doc <- add_slide(doc, layout = "Title and Content",
  master = "Office Theme")
img.file <- file.path( R.home("doc"), "html", "logo.jpg" )
doc <- ph_with(x = doc, external_img(img.file, 100/72, 76/72),
               location = ph_location_right(), use_loc_size = FALSE )

svg_file <- file.path(R.home(component = "doc"), "html/Rlogo.svg")
if( require("rsvg") ){
  doc <- ph_with(x = doc, external_img(svg_file),
    location = ph_location_left(),
    use_loc_size = TRUE )
}



# unordered_list ----
ul <- unordered_list(
  level_list = c(1, 2, 2, 3, 3, 1),
  str_list = c("Level1", "Level2", "Level2", "Level3", "Level3", "Level1"),
  style = fp_text(color = "red", font.size = 0) )
doc <- add_slide(doc, layout = "Title and Content",
                 master = "Office Theme")
doc <- ph_with(x = doc, value = ul,
               location = ph_location_fullsize() )

print(doc, target = fileout )
# }
Documentation reproduced from package officer, version 0.3.5, License: GPL-3

Community examples

Looks like there are no examples yet.