[R] multiple plots using summary in rms package

Frank E Harrell Jr f.harrell at vanderbilt.edu
Tue Dec 8 00:31:47 CET 2009


Mike,

You are not using rms functions in your example; you are using Hmisc's 
summary.formula function and its plot method.  For method='reverse', 
multiple plots may be produced by the plot method so par(mfrow=c( )) is 
not well defined.  There is also a problem with the dotchart2 function 
(called by plot.summary.formula.reverse) in this context, as it wants to 
call plot.new().

Frank

Mike Babyak wrote:
> Dear All,
> 
> I wonder if someone can point me in the right direction here.  I'm working
> with the rms library, R 2.9.2 under Windows XP.
> 
> I'm trying to arrange two plots side by side for a colleague.  mfrow or
> mfcol do not seem to work, however, so I am obviously missing something
> important.  I know that there have been changes in the graphics from Design
> to rms, but am just not sure where to find specific documentation about this
> particular issue.
> 
> Below is the code I'm using.  If I run the code except for the last plot
> call, the first plot is correctly produces in the first column with empty
> space for the second plot in col 2.  But when I add the second plot call, it
> just overwrites the first plot in col1 on the left.
> 
> If I run the code below using something like plot(x~y) and plot(a~b) instead
> of the two rms summary objects, it works fine, so I am assuming there is
> something about rms I am missing.
> 
> I'd be happy to provide some data if that would help.
> 
> Any guidance would be greatly appreciated.
> 
> Thanks,
> 
> Mike Babyak
> Duke University Medical Center
> 
> 
> ########################################################
> #summary of dietary variables broken out by Groups A, B, and C
> sumfc<-summary(Group~fcgrain+fcveg+fcfruit+fcmeat+fcdairy+fcnsl+
>         fcfat+fcsatfat+fcsweet+fcsod,
> method='reverse', overall=F,  test=F)
> 
> sumpc<-summary(Group~pcgrain+pcveg+pcfruit+pcmeat+pcdairy+
>         pcnsl+pcfat+pcsatfat+pcsweet+pcsod,
>     method='reverse', overall=F,  test=F)
> 
> par(mfcol=c(1,2),oma=c(1,0,4,0))
> plot(sumfc, which='categorical',
> main='Full Compliance',pch=c('A','B','C'))
>  Key(0,-.1)
> 
> plot(sumpc, which='categorical',
> main='At Least Partial Compliance',pch=c('A','B','C'))
> mtitle("Dietary Adherence")


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




More information about the R-help mailing list