[R] vis.gam zlab problem

David Winsemius dwinsemius at comcast.net
Fri Oct 28 07:26:28 CEST 2011


On Oct 27, 2011, at 6:13 PM, wildlifeduke wrote:

> I am using the mgcv package to develop vis.gam plots and having  
> trouble
> figuring out how to relabel the z-axis (image attached).  It is  
> currently
> labeled as "linear predictor," but I would like to change it to a  
> different
> name.  Currently I am using this code:
> vis.gam(model1,theta=320,ticktype="detailed",color="gray",nCol=12,
> zlab="BCS")
>
> However, when run R states:
> Error in persp.default(m1, m2, z, col = col, zlim = c(min.z, max.z),  
> xlab =
> view[1],  :
>  formal argument "zlab" matched by multiple actual arguments
>

`vis.gam` creates that name and it gets pasted into a string that  
result in a collision with your supplied argument at the point where  
they a both passed to `persp`. You will need to hack that code to  
circumvent, or extract the relevant vectors from the gam fit an dbuild  
a plot on your own.

The code to replace would be

  if (type == "link")
         zlab <- paste("linear predictor")

Or perhaps intercept the handling of "stub"'s construction at the end:

             stub <- paste(ifelse("xlab" %in% dnm, "", ",xlab=view[1]"),
                 ifelse("ylab" %in% dnm, "", ",ylab=view[2]"),
                 ifelse("main" %in% dnm, "", ",zlab=zlab"), ",...)",
                 sep = "")
             if (color == "bw") {
                 op <- par(bg = "white")
                 txt <- paste("persp(m1,m2,z,col=\"white 
\",zlim=c(min.z,max.z) ",
                   stub, sep = "")
                 eval(parse(text = txt))
                 par(op)
             }
             else {
                 txt <-  
paste("persp(m1,m2,z,col=col,zlim=c(min.z,max.z)",
                   stub, sep = "")
                 eval(parse(text = txt))
-- 
David.

>
>
> Any assistance would be greatly appreciated!!
>
> -Jared http://r.789695.n4.nabble.com/file/n3946213/BCS_Plot.jpeg
>
> --
> View this message in context: http://r.789695.n4.nabble.com/vis-gam-zlab-problem-tp3946213p3946213.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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
West Hartford, CT



More information about the R-help mailing list