Reprex:
dat <- data.frame(x = structure(19951, class = "Date"),
y = c(109237907428.42064, 109237907428.42065)
)
p <- lattice::xyplot(y ~ x,
data = dat,
panel = function(x,y,...) {
lattice::panel.grid(h = -5,
v = 0,
col = "lightgray"
)
lattice::panel.xyplot(x, y, ...)
}
)
print(p, panel.error = NULL)
The root cause of the problem appears to be inside lattice::panel.grid where it does this (slightly paraphrased to avoid method dispatch)
limits <- current.panel.limits()
scale <- limits$ylim
at <- lattice:::formattedTicksAndLabels.default(scale, n = 5L)$at
at <- at[at > min(scale) & at < max(scale)]
at which point at has length zero, which gets passed to grid::grid.segments which then passes it to grid::segmentsGrob which then passes it to grid::unit which throws the error.
I am not sure whether there is a foolproof way to deal with such conditions gracefully, but thank you for considering nonetheless.
Reprex:
The root cause of the problem appears to be inside
lattice::panel.gridwhere it does this (slightly paraphrased to avoid method dispatch)at which point
athas length zero, which gets passed togrid::grid.segmentswhich then passes it togrid::segmentsGrobwhich then passes it togrid::unitwhich throws the error.I am not sure whether there is a foolproof way to deal with such conditions gracefully, but thank you for considering nonetheless.