[R] Isolating a single plot from plots produced simultaneously

David Winsemius dwinsemius at comcast.net
Tue Jun 9 17:23:09 CEST 2009


This is almost certainly a device-dependent issue, which is the reason  
the Posting Guide requests that you include such details.

On a Mac using the GUI interface, one can scroll backwards through the  
graphics windows with <cmd>-<left arrow>. With the plot of interest as  
the focus one can then issue additonal plotting function calls such as  
lines() or points() and then save the plots as pdf if the default  
Qartz device has been used.

I suspect there are equivalent facilities for Windows and Linux  
installations and encourage you to try reading the help pages:

?Devices         #should bring up useful (installation-specific)  
information

-- 
David
On Jun 9, 2009, at 10:36 AM, Laura Bonnett wrote:

> Dear R-Help,
>
> I am using the 'mfp' package.  It produces three plots (as I am using
> the Cox model) simultaneously which can be viewed together using the
> following code:
>
> fit <- mfp(Surv(rem.Remtime,rem.Rcens)~fp(age) 
> +strata(rpa),family=cox,data=nearma,select=0.05,verbose=TRUE)
> par(mfrow=c(2,2))
> plot(fit)
>
> They can be viewed separately but the return key must be pressed after
> each graph appears (Click or hit ENTER for next page).
>
> I'd like to isolate the second plot produced (the estimated functional
> form of the influence of age on the log relative hazard) so that I can
> use the 'points' function to add the linear predictors for the
> untransformed and the log-transformed models.  In the usual situation
> one would produce a plot and then type:
>
> coxfitu <- coxph(Surv(rem.Remtime,rem.Rcens)~age 
> +strata(rpa),data=nearma)
> points(coxfitu$linear.predictor,col=2)
> coxfitl <- coxph(Surv(rem.Remtime,rem.Rcens)~log(age) 
> +strata(rpa),data=nearma)
> points(coxfitl$linear.predictor,col=3)
>
> Can anyone tell me how to isolate just the second plot produced?
>
> Thank you for your help,
>
> Laura
>
> ______________________________________________
> R-help at r-project.org 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list