Description Usage Arguments Details Examples
View source: R/increase_diff.R
Rearrange a sorted numeric sequence so that the difference between subsequent elements is increased
1 |
x |
a numeric sequence |
step |
how long a step the difference is considered for. |
With step=2
(default) only the difference between immediate neighbours are
considered; the difference between every second element will remain small,
or rather reduced, compared to the original sequence. With step=3
say,
differences of both lag 1 and 2 is increased, but the difference of lag 1 will
be less than if a step of 2 was used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | x <- 1:100
diff(x)
diff(incdiff(x, 2))
diff(incdiff(x, 3))
diff(incdiff(x, 2), 2)
diff(incdiff(x, 3), 2)
# incdiff will introduce a periodicity equal to the step length
acf(incdiff(x, 10))
# useful for making a sequence of colours more distinct
y <- seq(0.4, 1, l=18)
cols1 <- hsv(y, 1, y)
cols2 <- hsv(y, 1, incdiff(y, 3))
plot(y, col=cols1, pch=16, cex=5, ylim=c(0.4, 1.5))
points(y+0.5, col=cols2, pch=16, cex=5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.