This function takes in a vector of measurements and computes overlapping bins of observations, and applies a jittering function within each overlapping bin.
1 2 3 4 5 6 
x 
The values that should be jittered. Notice that these are used to determine which are overlapping, and should not be though of as xaxis positions (see example). 
q 
Probability quantiles where the ends of the bins should be placed 
type 
Type of jittering, by default it is used to choose which element (1 or 2) of the list of jittering functions is chosen as the final jittering function. Customized functions may be provided to the jitterfuncsparameter. 
amount 
Amount of jittering (here deterministic shifting) for the jittering function 
jitterfuncs 
List of possible jittering functions for n overlapping values. The jittering function at list position 'type' is chosen 
jits 
Final jittering function from the jitterfuncslist 
The smart jittering is applied to the xparameter values, and returns a vector of shifting amounts per each observation. Notice that in the typical case, parameter 'x' are the desired response values e.g. among the yaxis, and the returned value of smartjitter are the amounts of jittering done on the xaxis of a plot.
The function returns a vector of values with same length as x. The values in this vector indicate what should be the shifting per each observation, if the observations should be jittered along an another axis.
Teemu Daniel Laajala <teelaa@utu.fi>
1 2 3 4 5 6 7 8 9 10 11  data(vcapwide)
plot.new()
plot.window(xlim=extendrange(c(0,1)), ylim=extendrange(vcapwide[,"PSAWeek4"]))
y1 < vcapwide[vcapwide[,"CastrationDate"]=="100413","PSAWeek4"]
y2 < vcapwide[vcapwide[,"CastrationDate"]=="170413","PSAWeek4"]
points(x=0+smartjitter(y1, type=2, amount=0.02), y=y1)
points(x=1+smartjitter(y2, type=2, amount=0.02), y=y2)
axis(1, at=c(0,1), labels=c("10.04.13", "17.04.13"))
axis(2); box()
title(ylab="PSA at week 4", xlab="Castration batches")

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.