Learn R Programming

R2PPT (version 2.2.0)

PPT.AddDataFrame: Adds a R data frame to the current slide

Description

Adds a R data frame to the current slide using the 'AddOLEObject' PowerPoint method.

Usage

PPT.AddDataFrame(ppt, df = stop("Data frame must be specified"), 
size = c(120, 110, 480, 320), row.names = TRUE, col.names = TRUE)

Arguments

ppt

Required list of COM objects as initialised by PPT.Init. See example.

df

a R dataframe.

size

Optional numeric vector of size 4 (Left,Top,Width,Height) giving the dimensions of the R data frame as it appears in the PowerPoint slide.

row.names

logical; include data frame row names?

col.names

logical; include data frame column names?

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.

Details

The function saves the data frame as a temporary csv file and then inserts this into presentation using the PowerPoint 'AddOLEObject' method. PowerPoint treats this as an embedded Excel file which is convenient for further editing of the data frame.

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,PPT.AddGraphicstoSlide

Examples

Run this code
# NOT RUN {
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2,10,20, labels=c("Ctl","Trt"))
weight <- c(ctl, trt)
my.df<-data.frame(weight=weight,group=group)

opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
plot(lm(weight ~ group,data=my.df), las = 1)      # Residuals, Fitted, ...
par(opar)


myPres<-PPT.Init(visible=TRUE)
myPres<-PPT.AddBlankSlide(myPres)
myPres<-PPT.AddGraphicstoSlide(myPres,size= c(200, 10, 500, 500))
myPres<-PPT.AddDataFrame(myPres, df = my.df,row.names=FALSE,size=c(30,100,100,300))
myPres<-PPT.Present(myPres)

### Double click the data frame in PowerPoint to edit further..

# }

Run the code above in your browser using DataLab