# [Rd] Re: [R] Help with a Lattice plot that fails with an empty unique combination

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Jun 10 09:04:17 CEST 2004

```This is surely a bug in jitter, which should pass through a 0-length input
unchanged as S does (and I will fix that).

I do wonder what jitter should do with a length-1 input.  It does change
it, using a rather arbitrary notion of the scale of the change (as does
S).  Given the description

'jitter(x,...)' returns a numeric of the same length as 'x', but
with an 'amount' of noise added in order to break ties.

it appears it should not change a length-1 input.

Opinions?

On Wed, 9 Jun 2004, Deepayan Sarkar wrote:

> On Wednesday 09 June 2004 01:58, Tom Mulholland wrote:
> > While using Lattice I received the following error.
> >
> > Error in if (xx != 0) xx/10 else z/10 : argument is of length zero
> > In addition: Warning messages:
> > 1: is.na() applied to non-(list or vector) in: is.na(x)
> > 2: is.na() applied to non-(list or vector) in: is.na(x)
> > 3: no finite arguments to min; returning Inf
> > 4: no finite arguments to max; returning -Inf
> > 5: NaNs produced in: log(x, base)
> > Can anyone point me in the right direction.
>
> A traceback() shows that this is happening due to jitter() being called
> with a length-0 numeric. I have added a check in panel.stripplot. Until
> the next release, you can work around it by:
>
>
> assignInNamespace("panel.stripplot",
>     function(x, y, jitter.data = FALSE, factor = 0.5,
>              horizontal = TRUE, groups = NULL, ...)
> {
>     if (length(x) < 1) return()
>     x <- as.numeric(x)
>     y <- as.numeric(y)
>     y.jitter  <-
>         if (horizontal && jitter.data)
>             jitter(y, factor = factor) else y
>     x.jitter  <-
>         if (!horizontal && jitter.data)
>             jitter(x, factor = factor) else x
>     if (is.null(groups)) panel.xyplot(x = x.jitter,
>         y = y.jitter, ...) else
>     panel.superpose(x = x.jitter, y = y.jitter,
>         groups = groups, ...)
> }, "lattice")
>
>
> Deepayan
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>

--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

```