Last chance! 50% off unlimited learning
Sale ends in
add a ggplot as a png image into an rdocx object
body_add_gg(x, value, width = 6, height = 5, style = NULL, ...)
an rdocx object
ggplot object
height in inches
height in inches
paragraph style
Arguments to be passed to png function.
# NOT RUN {
if( require("ggplot2") ){
doc <- read_docx()
gg_plot <- ggplot(data = iris ) +
geom_point(mapping = aes(Sepal.Length, Petal.Length))
if( capabilities(what = "png") )
doc <- body_add_gg(doc, value = gg_plot, style = "centered" )
print(doc, target = tempfile(fileext = ".docx") )
}
# }
Run the code above in your browser using DataLab