R package
compstatslib
Interactive gadgets and plotting functions for data sets and statistical concepts, in two and three dimensions. It runs in RStudio.
Part of it works on your own data. The rest simulates a concept instead of plotting your data, for class demonstrations, homework, and self-study.
install.packages("compstatslib")
The package is on CRAN. For the development version, run devtools::install_github("compstatslib/compstatslib"). The source is on GitHub.
Three kinds of function
The families above group the functions by what they are for. Inside each family the same three kinds appear.
- Interactive functions let you drive a visualization with the mouse or the keyboard.
- Plot functions draw data, a distribution, or a concept. Most are the non-interactive counterpart of an interactive function.
- Code functions stand as examples to read. They run, but the value is in the code, as in machine_precision().
The 2D fits are sized for small data. plot_regression() draws in a fixed window, and plot_pca() expects two columns named x and y. The 3D functions take any data frame, with control over the axes, the color mapping, the aspect ratio, and the camera.
An interactive session ends as one line of code
Every gadget hands its final state back when you click Done. It prints the plot call that reproduces the screen, viewing angle included. Paste that line into a script, an Rmd, or a figure-generating file.
plot_moderation_3d(formula = y ~ x * z, data = moderation_data, z_rot = 125)
A gadget that collects points returns a data frame. A gadget that collects settings returns a named list, ready for do.call(). A result you would not retype rides along as an attribute, such as the prcomp() fit from interactive_pca() or the accumulated draws from interactive_sampling().
Where the 3D work is going
The 3D visualizations are the part of the package meant to grow past the classroom, toward figures good enough for textbooks and manuscripts. They are not there yet. The future-work notes list the gaps.
Soumya Ray maintains the package. Daniele Melotti is a co-author. Several of the plotting and interactive functions grew out of work he did as a student under Soumya Ray's supervision. Issues and pull requests are welcome.