Learn R Programming

rtf (version 0.4-6)

addPlot.RTF: Insert a plot into the RTF document

Description

Insert a plot into the RTF document.

Usage

## S3 method for class 'RTF':
addPlot(this, plot.fun=plot.fun, width=3, height=0.3, res=300, ...)

Arguments

this
An RTF object.
plot.fun
Plot function.
width
Plot output width in inches.
height
Plot output height in inches.
res
Output resolution in dots per inch.
...
Arguments for plot.fun.

Details

Plots are added to the document as PNG objects. This function will work with all base graphics methods for plotting. For more sophisticated plots, you may need to wrap your plot code into a function, and then pass a reference to that function to this method. The parameters for the plot method would then get passed in as '...' above.

To output a ggplot2 plot, simply assign the plot to a variable. Then use 'print' as the plot function and pass in the plot variable assigned above.

See Also

For more information see RTF.

Examples

Run this code
rtf<-RTF("test_addPlot.doc",width=8.5,height=11,font.size=10,omi=c(1,1,1,1))
 addPlot(rtf,plot.fun=plot,width=6,height=6,res=300, iris[,1],iris[,2])
 done(rtf)

Run the code above in your browser using DataLab