[R] "ask=F" option with plot.gam

David Winsemius dwinsemius at comcast.net
Thu Oct 8 22:49:52 CEST 2009


On Oct 8, 2009, at 4:40 PM, Marc Carpentier wrote:

> Hello.
> I'd like to plot only one component smooth function of a gam model  
> (for example the second) (library mgcv). So, I did :
> plot(my.gam, select=2, ask=F)
> But plot.gam doesn't seem to understand the "ask" option, so I can't  
> deactivate the interactive plotting. I tried and failed by forcing  
> it through :
> par(ask=F)
> And the "page" option of plot.gam (automatic layout) seems to be in  
> conflit with the one "select" :
> plot(my.gam, select=2, page=1) #does par(mfrow=c(2,1) (if 2 "s()" in  
> the model) even though it plots only the second function...
> Does anyone have a tip on this ?
> (it's to use in a Sweave document, not just bug tracking...)
> Thank you for your help.

Have you tried putting it in the document and letting it be parsed.  
The function is currently set up to check whether the session is  
interactive or not:

----code snippet---
  if ((pages == 0 && prod(par("mfcol")) < n.plots &&  
dev.interactive()) ||
         pages > 1 && dev.interactive())
         ask <- TRUE
     else ask <- FALSE
     if (ask) {
         oask <- devAskNewPage(TRUE)
         on.exit(devAskNewPage(oask))
---end snippet--------

.... and you could hack the function to your liking.
--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list