[R] Adding a table to a plot area

Charles Annis, P.E. Charles.Annis at StatisticalEngineering.com
Sat Sep 22 16:48:31 CEST 2007

Professor Harrell:

I'm one of the slow kids and am having trouble following instructions, which
state, in part:

Download fragmaster.pl from 
and save it in ~/bin and chmod a+x fragmaster.pl

Finding fragmaster.pl was easy, as was saving it to ~/bin in my R2.5.0

A search for "chmod" returned only "chmod.al" in my folder 
C:\Program Files\Perl\lib\auto\POSIX

Not surprisingly running the script is unsuccessful:
> library(Hmisc)
> postscript('psfrag2_fm.eps', pointsize=12,
+            onefile=FALSE, paper='special',
+            horizontal=FALSE, height=4, width=5)
> par(mar=c(3, 3.25, .25, .5), lwd=1.5, mgp = c(2, 0.45, 0), tcl = -0.4)
> x <- seq(0,15,length=100)
> plot(x, dchisq(x, 5), ylab='fx', type='l')   # fx will be substituted by
> text(10, .13, 'ww', adj=0)  # LaTeX table will be put at location of ww in
> dev.off()
null device 
> x <- cbind(Age=format(c(23.0,9.7)), Sex=c('Male','Female'))
> tab <- latexTabular(x, align='rl')  # new function in Hmisc
Error: could not find function "latexTabular"
> cat('\\psfrag{ww}{\\small', tab, '}',
+     '\\psfrag{fx}{$f(x)$}',
+     sep='\n', file='psfrag2_fm')
Error in cat("\\psfrag{ww}{\\small", tab, "}", "\\psfrag{fx}{$f(x)$}",  : 
        object "tab" not found
> system('fragmaster.pl psfrag2')
Warning message:
Impossible to run C:\PROGRA~1\R\R-25~1.0\bin\FRAGMA~1.PL psfrag2 

Please help me do whatever this means:
" ... save it in ~/bin and chmod a+x fragmaster.pl"


Charles Annis, P.E.

System Details:
R2.5.0 running on a DELL 3GHz Pentium 4, 2 Gig RAM, WinXP service pack 2

Charles.Annis at StatisticalEngineering.com
phone: 561-352-9699
eFax:  614-455-3265

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Frank E Harrell Jr
Sent: Friday, September 21, 2007 6:42 PM
To: Judith Flores
Cc: RHelp
Subject: Re: [R] Adding a table to a plot area

Judith Flores wrote:
> Is there a command to insert a table into the plot
> area other that using text?
> Thank you.

To me the only completely satisfying approach is to use LaTeX and psfrag 
in you want great alignment and other features.  A howto with R is at 
http://biostat.mc.vanderbilt.edu/PsFrag .  This uses the fragmaster perl 
script which runs LaTeX from within R to make the final graphics file 


Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list