body_remove
From officer v0.3.4
by David Gohel
remove an element
remove element pointed by cursor from a Word document
Usage
body_remove(x)
Arguments
- x
an rdocx object
Examples
# NOT RUN {
library(officer)
library(magrittr)
str1 <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " %>%
rep(20) %>% paste(collapse = "")
str2 <- "Drop that text"
str3 <- "Aenean venenatis varius elit et fermentum vivamus vehicula. " %>%
rep(20) %>% paste(collapse = "")
my_doc <- read_docx() %>%
body_add_par(value = str1, style = "Normal") %>%
body_add_par(value = str2, style = "centered") %>%
body_add_par(value = str3, style = "Normal")
new_doc_file <- print(my_doc,
target = tempfile(fileext = ".docx"))
my_doc <- read_docx(path = new_doc_file) %>%
cursor_reach(keyword = "that text") %>%
body_remove()
print(my_doc, target = tempfile(fileext = ".docx"))
# }
Community examples
Looks like there are no examples yet.