1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| panel.average_weight<-function (x, y, fun = mean, horizontal = TRUE, lwd = reference.line$lwd,
lty = reference.line$lty, col, col.line = reference.line$col,
type = "l", ...)
{
x <- as.numeric(x)
y <- as.numeric(y)
reference.line = trellis.par.get("reference.line")
if (!missing(col)) {
if (missing(col.line))
col.line <- col
}
if (horizontal) {
vals <- unique(sort(y))
yy <- seq_along(vals)
xx <- numeric(length(yy))
for (i in yy) xx[i] <- fun(x[y == vals[i]], weight)
panel.lines(xx, vals[yy], col = col.line, lty = lty,
lwd = lwd, ...)
}
else {
vals <- unique(sort(x))
xx <- seq_along(vals)
yy <- numeric(length(xx))
for (i in xx) yy[i] <- fun(y[x == vals[i]], weight)
panel.lines(vals[xx], yy, col = col.line, lty = lty,
lwd = lwd, ...)
}
} |
Partager