[R] xyplot: logarithmic y-axis

Deepayan Sarkar deepayan.sarkar at gmail.com
Sat Dec 16 00:43:57 CET 2006


On 12/15/06, RMan54 <RMan54 at cox.net> wrote:
>
> I added logY as the last argument to xyplot and in my curve function. I got
> the following error message:
>
> Error in myCurve(x) : argument "log" is missing, with no default
>
> myCurve <-function(x, log) {
>     f <- ... # calculate curve here
>     if (log==T) f <- log10(f)
>     return(f)
> }
>
> logY=T
> xyplot(Conc ~ Time | Subj,
>        groups=Dose,
>        data = mydata,
>        scales=list(x=list(at=seq(0,96,24)), y=list(log=logY)),
>        panel = function(...) {
>            panel.abline(h=c(0, 50, 100, 150, 200, 250) ,
>                       v=c(0,24,48,72,96), col.line="gray")
>            panel.xyplot(...)
>            panel.curve(myCurve, from=0, to=96, n=300, ..., log=logY)
>            },
>        logY
>        )

You need to learn more about (1) R functions and (2) R's scoping
rules. Your last argument (logY) is not doing what you think it's
doing (which doesn't really matter because of the scoping rules).

Your error is caused because in

panel.curve(myCurve, from=0, to=96, n=300, ..., log=logY)

the 'log' argument is not being passed to myCurve (nor is it supposed
to). However, you should be able to replace it by

panel.curve(myCurve(x, log = logY), from=0, to=96, n=300, ...)

-Deepayan



More information about the R-help mailing list