officer (version 0.1.3)

body_add_gg: add ggplot

Description

add a ggplot as a png image into an rdocx object

Usage

body_add_gg(x, value, width = 6, height = 5, style = NULL)

Arguments

x

an rdocx object

value

ggplot object

width

height in inches

height

height in inches

style

paragraph style

Examples

Run this code
library(ggplot2)

doc <- read_docx()

gg_plot <- ggplot(data = iris ) +
  geom_point(mapping = aes(Sepal.Length, Petal.Length))

doc <- body_add_gg(doc, value = gg_plot, style = "centered" )

print(doc, target = "body_add_gg.docx" )

Run the code above in your browser using DataCamp Workspace