animation (version 2.6)

moving.block: Cycle through an R object and plot each subset of elements

Description

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.

Usage

moving.block(dat = runif(100), block, FUN, ...)

Arguments

dat

a numeric vector or two-column matrix

block

block length (i.e. how many elements are to be plotted in each step)

FUN

a plot function to be applied to the subset of data

other arguments passed to FUN

Value

NULL

Details

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.

References

Examples at https://yihui.name/animation/example/moving-block/