rtf.forest.plot: Get an RTF encoded forest plot

Description Usage Arguments Details Examples

View source: R/forest.plot.R

Description

Get an RTF encoded forest plot.

Usage

1
2
rtf.forest.plot(x=1.25, min=0.5, max=2, xlim=c(0.1, 12), width=3, height=0.3, cex=1,
  lwd=0.75, res=300)

Arguments

x

x (e.g. hazard ratio).

min

Minimum whisker (e.g. lower bound of 95% hazard ratio CI).

max

Maximum whisker (e.g. upper bound of 95% hazard ratio CI).

xlim

A vector specifying the x limits.

width

Plot width in inches.

height

Plot height in inches.

cex

A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default.

lwd

Line width.

res

Output resolution in dots per inch.

Details

Create a forest plot and convert PNG to RTF code. This is useful for embedding into a data frame of hazard ratios and then writing an RTF output file. See the example below for usage.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 ## Not run: 
 tab<-data.frame(
	Label=c("Test1","Test2","Test3"),
 	HR=c(1,2,0.45),
 	Lower.CI=c(0.5,1.1,0.25),
 	Upper.CI=c(2,3.5,0.9),
 	stringsAsFactors=FALSE,
 	check.names=FALSE)

 # create forest plots by row
 forest.plot.args<-list(xlim=c(0.1,5),width=3.0,height=0.3,cex=1,lwd=0.75,res=300)
 tab$"HR Plot (log scale)"<-mapply(rtf.forest.plot,tab$HR,tab$Lower.CI,tab$Upper.CI,
			MoreArgs=forest.plot.args)

 # rbind the x-scale to the table in the plot column
 xscale<-rtf.forest.plot.xscale(xlim=c(0.1,5),width=3.0,height=0.3,cex=1,
 			lwd=0.75,res=300)

 tab<-data.frame(lapply(tab, as.character),
 			stringsAsFactors=FALSE,
			check.names=FALSE)

 tab<-rbind(tab,list("","","","",xscale))

 # write the RTF output
 rtf<-RTF("test_rtf.forest.plot.doc",width=8.5,height=11,font.size=10,omi=c(1,1,1,1))
 addTable(rtf,tab,col.widths=c(0.75,0.75,0.75,0.75,3))
 done(rtf)
 
## End(Not run)
 

rtf documentation built on March 26, 2020, 7:40 p.m.