Learn R Programming

rtf (version 0.4.1)

RTF: The RTF class

Description

This is the class representing an RTF file output.

Package: rtf Class RTF Object ~~| ~~+--RTF Directly known subclasses: public static class RTF extends Object

Usage

RTF(file="", width=8.5, height=11, omi=c(1, 1, 1, 1), font.size=10)

Arguments

file
The path of the output file.
width
The width of the output page.
height
The width of the output page.
omi
A vector representing the outer margins in inches (bottom, left, top, right).
font.size
Default font size for the document in points.
...
Not used.

Fields and Methods

Methods: rll{ addHeader - addNewLine - addPageBreak - addParagraph - addPlot - addTable Add a table to the RTF document. addText - addTrellisObject - decreaseIndent - done Write and close the RTF output. endParagraph - increaseIndent - setFontSize - startParagraph - view View encoded RTF. }

Methods inherited from Object: [[, [[<-, $, $<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, gc, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, objectSize, print, registerFinalizer, save

See Also

For more information see RTF.

Examples

Run this code
output<-"test.rtf.doc"
 png.res<-300

 rtf<-RTF(output,width=8.5,height=11,font.size=10,omi=c(1,1,1,1))
 addHeader(rtf,title="Test",subtitle="2011-08-15\n")
 addPlot(rtf,plot.fun=plot,width=6,height=6,res=300, iris[,1],iris[,2])

 # Try trellis plots
 if(require(lattice)) {
 	# single page trellis objects
 	addPageBreak(rtf, width=11,height=8.5,omi=c(0.5,0.5,0.5,0.5))

 	p <- histogram( ~ height | voice.part, data = singer, xlab="Height")
 	addTrellisObject(rtf,trellis.object=p,width=10,height=7.5,res=png.res)

 	p <- densityplot( ~ height | voice.part, data = singer, xlab = "Height")
 	addTrellisObject(rtf,trellis.object=p,width=10,height=7.5,res=png.res)

 	# multipage trellis object
 	p2<-xyplot(uptake ~ conc | Plant, CO2, layout = c(2,2))
 	addTrellisObject(rtf,trellis.object=p2,width=6,height=6,res=png.res)
 }

 addPageBreak(rtf, width=6,height=10,omi=c(0.5,0.5,0.5,0.5))
 addTable(rtf,as.data.frame(head(iris)),font.size=10,row.names=FALSE,NA.string="-",
          col.widths=rep(1,5))

 tab<-table(iris$Species,floor(iris$Sepal.Length))
 names(dimnames(tab))<-c("Species","Sepal Length")
 addParagraph(rtf,"\n\nHere's a new paragraph with another table:\n")
 addTable(rtf,tab,font.size=10,row.names=TRUE,NA.string="-",
          col.widths=c(1,rep(0.5,4)) )

 done(rtf)

Run the code above in your browser using DataLab