remove_slide: Remove slide(s)

View source: R/pptx_slide_manip.R

remove_slideR Documentation

Remove slide(s)

Description

Remove one or more slides from a pptx presentation.

Usage

remove_slide(x, index = NULL, rm_images = FALSE)

Arguments

x

an rpptx object

index

slide index or a vector of slide indices to remove, default to current slide position.

rm_images

unused anymore.

Note

cursor is set on the last slide.

See Also

read_pptx(), ph_with(), ph_remove()

Other functions to manipulate slides: add_slide(), move_slide(), on_slide(), set_notes()

Examples

library(officer)

x <- read_pptx()
x <- add_slide(x, "Title and Content")
x <- remove_slide(x)

# Remove multiple slides at once
x <- read_pptx()
x <- add_slide(x, "Title and Content")
x <- add_slide(
  x,
  layout = "Two Content",
  `Title 1` = "A title",
  dt = "Jan. 26, 2025",
  `body[2]` = "Body 2",
  left = "Left side",
  `6` = "Footer"
)
x <- add_slide(
  x,
  layout = "Two Content",
  `Title 1` = "A title",
  dt = "Jan. 26, 2025",
  `body[2]` = "Body 2",
  left = "Left side",
  `6` = "Footer"
)
x <- add_slide(x, "Title and Content")
x <- remove_slide(x, index = c(2, 4))
pptx_file <- print(x, target = tempfile(fileext = ".pptx"))
pptx_file

officer documentation built on Jan. 17, 2026, 1:06 a.m.