Skip to content

xyplot infelicity when a panel does not contain non-NA values #45

Description

@tyner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions