[R] how to place a rug on only the x-axis in a scatterplot with lattice

Christopher W Ryan cry@n @end|ng |rom b|ngh@mton@edu
Tue Nov 5 17:40:45 CET 2019


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]]



More information about the R-help mailing list