From ripley at stats.ox.ac.uk  Thu Jun 10 09:04:17 2004
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu Jun 10 09:04:20 2004
Subject: [Rd] Re: [R] Help with a Lattice plot that fails with an empty
 unique combination
In-Reply-To: <200406091804.38752.deepayan@stat.wisc.edu>
Message-ID: <Pine.LNX.4.44.0406100754520.3886-100000@gannet.stats>

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@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 
> 

-- 
Brian D. Ripley,                  ripley@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


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