Jitter (Add Noise) to Numbers
Add a small amount of noise to a numeric vector.
jitter(x, factor = 1, amount = NULL)
- numeric vector to which jitter should be added.
- numeric; if positive, used as amount (see below),
= 0the default is
factor * z/50.
factor * d/5where
dis about the smallest difference between
The result, say
r <- x + runif(n, -a, a)
n <- length(x) and
a is the
argument (if specified).
z <- max(x) - min(x) (assuming the usual case).
a to be added is either provided as positive
amount or otherwise computed from
amount == 0, we set
a <- factor * z/50 (same as S).
NULL (default), we set
a <- factor * d/5 where d is the smallest
difference between adjacent unique (apart from fuzz)
jitter(x, ...)returns a numeric of the same length as
x, but with an
amountof noise added in order to break ties.
Chambers, J. M., Cleveland, W. S., Kleiner, B. and Tukey, P.A. (1983) Graphical Methods for Data Analysis. Wadsworth; figures 2.8, 4.22, 5.4.
Chambers, J. M. and Hastie, T. J. (1992) Statistical Models in S. Wadsworth & Brooks/Cole.
rug which you may want to combine with
round(jitter(c(rep(1, 3), rep(1.2, 4), rep(3, 3))), 3) ## These two 'fail' with S-plus 3.x: jitter(rep(0, 7)) jitter(rep(10000, 5))