[R] Multiple rms summary plots in a single device

Frank Harrell f.harrell at vanderbilt.edu
Sat May 26 01:50:17 CEST 2012


Mike I don't know what you are trying to do with plot(summary( ... ~ ...)) as
this is not calling an rms function such as summary.rms.

To use mfrow and to control which variables are placed on one panel using
plot(summary(rms model fit object)) specify est.all=FALSE to summary( )
after specifying the limited list of variables to plot in the current panel.

Frank

Mike Harwood-2 wrote
> 
> I would like to incorporate multiple summary plots from the rms
> package into a single device and to control the titles, and also to
> open a new device when I reach a specified number of plots.  Currently
> I am only getting a single "plot(summary(" graph in the upper left-
> hand corner of each successive device.  However, in the rms
> documention I see instances of a loop being used with "par(mfrow(" for
> multiple plots in a single device(e.g. residuals.lrm), and these
> examples work on my system.  Please advise regarding options that must
> be specified to "plot(summary(", or in the construction of my loop.
> Below are sample code and my sessionInfo().  Please note that I am
> using data.table to facilitate my "real analysis", but I can replicate
> the issue with tData as a data.frame (using seg <- subset(tData,
> groups == segment) logic), but I included the data.table logic in case
> it may be having some influence.  Thank you!
> 
> Mike
> 
> 
> tData <- data.frame(groups=as.factor(1:8), low=as.factor(1:4)
> 	,high=as.factor(seq(100, 400, 100)),  rand=runif(400))
> tData <- data.table(tData)
> setkeyv(tData, 'groups')
> 
> 
> dd <- datadist(tData)
> options(datadist = 'dd')
> 
> doSumPlot <- function(segment){
> 	seg <<- tData[groups == segment,]
> 	plot(summary(rand ~
> 			+ low
> 			+ high
> 		,data = seg
> 		), main=paste('Group:', segment))
> }
> 
> 
> for(i in 1:length(levels(tData$groups))){
> 	cat('Group: ', i, '\n')
> 	if(i == 1 ){
> 		dev.new()
> 		par(mfrow=c(2,2))
> 		}
> 	if(i/5 == round(i/5, 0)){
> 		dev.new()
> 		par(mfrow=c(2,2))
> 		}
> 	# dev.new()
> 	doSumPlot(levels(tData$groups)[i])
> }
> 
> 
>> sessionInfo()
> R version 2.15.0 (2012-03-30)
> Platform: i386-pc-mingw32/i386 (32-bit)
> 
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
> 
> attached base packages:
> [1] splines   stats     graphics  grDevices utils     datasets
> methods
> [8] base
> 
> other attached packages:
> [1] rms_3.5-0        Hmisc_3.9-3      survival_2.36-14
> data.table_1.8.0
> 
> loaded via a namespace (and not attached):
> [1] cluster_1.14.2 grid_2.15.0    lattice_0.20-6 tools_2.15.0
> 
> ______________________________________________
> R-help@ mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/Multiple-rms-summary-plots-in-a-single-device-tp4631330p4631423.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list