For a long numeric vector or matrix (or data frame), we can plot only a
subset of its elements to take a closer look at its structure. With a moving
``block'' from the beginning to the end of a vector or matrix or any R
objects to which we can apply subset
, all elements inside the block
are plotted as a line or scatter plot or any customized plots.
moving.block(dat = runif(100), block, FUN, ...)
a numeric vector or two-column matrix
block length (i.e. how many elements are to be plotted in each step)
a plot function to be applied to the subset of data
other arguments passed to FUN
NULL
For a vector, the elments from i + 1
to i + block
will be
plotted in the i-th step; similarly for a matrix or data frame, a (scatter)
plot will be created from the i + 1
-th row to i + block
-th row.
However, this function is not limited to scatter plots or lines -- we can
customize the function FUN
as we wish.
Examples at https://yihui.org/animation/example/moving-block/