PPT.AddGraphicstoSlide: Adds an R graphics output to the current slide of current...

PPT.AddGraphicstoSlideR Documentation

Adds an R graphics output to the current slide of current PowerPoint presentation

Description

Adds an R graphics output to the current slide of the PowerPoint presentation using the PowerPoint 'AddPicture' method. Graphics output can either be a graphical output file or the current R graphics device as specified by dev.cur.

Usage

PPT.AddGraphicstoSlide(ppt, file = NULL, 
size = c(10, 10, 700, 500), dev.out.type = "jpeg")

Arguments

ppt

List of COM objects as initialised by PPT.Init. See example.

file

Optional filename giving the full file path to R graphics output. See example.

size

Optional numeric vector of size 4 (Left,Top,Width,Height) giving the dimensions of the R graphics in the PowerPoint slide. Defaults to c(10, 10, 700, 500) which covers most of the slide.

dev.out.type

Optional character type of output to use when using current graphics device. Defaults to "jpeg". Ignored if file is specified.

Value

ppt

Invisibly returns a list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,savePlot

Examples


## Not run: 
myPres<-PPT.Init(visible=TRUE)
myPres<-PPT.AddTitleSlide(myPres,title="How to add R graphics to PowerPoint!")

## Example adding graphic from file
myPres<-PPT.AddBlankSlide(myPres)
jpeg(file="testRplot1.jpeg",quality=100,height=960,width=960)
plot(rnorm(100))
dev.off()
# You must give full file path
myPres<-PPT.AddGraphicstoSlide(myPres,file=paste(getwd(),"testRplot1.jpeg",sep="/"))
unlink(paste(getwd(),"testRplot1.jpeg",sep="/"))
## Example adding graphic from current graphics device
myPres<-PPT.AddBlankSlide(myPres)
windows()
hist(rnorm(100))
myPres<-PPT.AddGraphicstoSlide(myPres,size= c(10, 10, 300, 500))
hist(runif(100))
myPres<-PPT.AddGraphicstoSlide(myPres,size= c(350, 10, 300, 500))


## End(Not run) 


R2PPT documentation built on April 26, 2022, 5:08 p.m.