Skip to content

jitter function when length(x) = 1

3 messages · Ingrid Charvet, Rui Barradas, David Winsemius

#
Hello,

A quick question relating to the documentation of the jitter function:
http://127.0.0.1:15714/library/base/html/jitter.html

jitter(x, factor = 1, amount = NULL)

"If amount is NULL (default), we set a <- factor * d/5 where d is the smallest difference between adjacent unique (apart from fuzz) x values."

Therefore if length(x) = 1, then d = 0, which means jitter(x) should be equal to x?
Which is not the case, i.e.
[1] 0.9842914

So how does jitter deals with this situation? Does it assume d = x?

Thanks
IC

________________________________
This message and any attachments contain information that may be RMS Inc. confidential and/or privileged. If you are not the intended recipient (or authorized to receive for the intended recipient), and have received this message in error, any use, disclosure or distribution is strictly prohibited. If you have received this message in error, please notify the sender immediately by replying to the e-mail and permanently deleting the message from your computer and/or storage system.
#
Hello,

You can see the code for jitter by typing its name at the prompt.
Inline.

Em 09-10-2014 18:19, Ingrid Charvet escreveu:
It doesn't assume, it computes range(x) and acts accordingly. The code 
lines are

     z <- diff(r <- range(x[is.finite(x)]))
     if (z == 0)
         z <- abs(r[1L])

It has the effect of setting z to x. Try running them. (And with x <- 2 
to see the difference.)

Hope this helps,

Rui Barradas
#
On Oct 9, 2014, at 10:19 AM, Ingrid Charvet wrote:

            
The code is right at your fingertips. Just type:

jitter