Reprex:
dat <- data.frame(x = 1:12,
p = gl(3L, 4L),
y = rep(c(NA, 1, 2), each = 4L)
)
ylim <- list(c(0, 2), c(1, 3), c(2, 4))
p <- lattice::xyplot(y ~ x | p,
data = dat,
ylim = ylim,
scales = list(relation = "free")
)
The warning which comes from latice:::limitsFromLimitlist is somewhat cryptic:
In limitlist[id] <- lim :
number of items to replace is not a multiple of replacement length
After some investigation it appears that when specifying per-panel ylim, it expects entries only for the subset of panels with non-NA values. However, as far as I can discern, this is not documented. If this is by design, it would be good to document, perhaps with some guidance around best practices (for example, is it better to remove NAs upfront, or is there a programmatic way to figure out the correct subset of ylim to pass, which might not be a trivial task if levels have been reordered and/or dropped (i.e. if the perm.cond and/or drop.unused.levels argument has been customized).
Thank you for considering.
Reprex:
The warning which comes from
latice:::limitsFromLimitlistis somewhat cryptic:After some investigation it appears that when specifying per-panel
ylim, it expects entries only for the subset of panels with non-NAvalues. However, as far as I can discern, this is not documented. If this is by design, it would be good to document, perhaps with some guidance around best practices (for example, is it better to removeNAs upfront, or is there a programmatic way to figure out the correct subset ofylimto pass, which might not be a trivial task if levels have been reordered and/or dropped (i.e. if theperm.condand/ordrop.unused.levelsargument has been customized).Thank you for considering.