Here's how you pass an argument down to the panel function. foo <- runif(30,0,5) y <- rnorm(30, mean = 10) xyplot(y~foo, panel = function(x,...) { panel.xyplot(x,..., col = "red") panel.rug(x, col="black") })
Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Nov 5, 2019 at 8:41 AM Christopher W Ryan <cr...@binghamton.edu> wrote: > The following produces a scatterplot with rugs on both the vertical and > horizontal axes. > > library(dplyr) > library(stringr) > library(lattice) > library(latticeExtra) > ## ..... > xyplot(scheduleInterval ~ calledForApptDate, data = dd.2, xlab = "Date > patient called for appointment", ylab = "Days in the future that patient > was scheduled", > panel = function(...) { > panel.xyplot(..., col = "red") > panel.smoother(..., span = 0.9, se = FALSE) > panel.rug(...) > }) > > I'd like a rug to appear only on the horizontal axis. None of the > following seem to be the correct syntax: > > panel.rug(..., y = NULL) > panel.rug(..., y = FALSE) > panel.rug(x) > panel.rug(x = ...) > > This does the job: > > xyplot(scheduleInterval ~ calledForApptDate, data = dd.2, xlab = "Date > patient called for appointment", ylab = "Days in the future that patient > was scheduled", > panel = function(...) { > panel.xyplot(..., col = "red") > panel.smoother(..., span = 0.9, se = FALSE) > panel.rug(x = dd.2$calledForApptDate) > }) > > but seems inadvisable. Shouldn't I be making use of ... for passing > arguments through to the panel.rug() function? Specifying a variable in a > dataframe by name isn't generalizable. > > Thanks. > > --Chris Ryan > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.