This package was designed mainly for interactions in statistical plots, a feature (nearly) missing in R for long. It contains most common statistical plots like histograms, scatter plots, bar charts, parallel coordinates plots, density plots, mosaic plots, boxplots, maps, missing value plots and time series plots. All plots support some common interactions as well as plot-specific interactions with the keyboard or the mouse.
The actual drawing is based on two packages qtbase and qtpaint,
which connect R to Qt. The data structure is based on plumbr and
objectSignals; the mutaframe
s and reference
classes are used extensively in this package. Usually there are listeners
(add_listener
) and signaling fields
(properties
) attached to data objects
(created by qdata
), so the plots can listen to the changes in
data (hence get updated). Note all the plots based on the same data object
are linked by default, so the interactions in one plot will be reflected in
other plots as well.
A plot can be in either the brush mode (default) or the identify mode. In the brush mode, we can use a rectangle brush to select elements in the plot; in the identify mode, the information about the identified elements under the mouse will be shown in the plot.
See common_mouse_press
, common_mouse_move
,
common_mouse_release
, common_key_press
and
common_key_release
for common interactions in all plots, and
the documentation of specific plots for other possible interactions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | library(cranvas)
str(tennis)
## the first step is always to create the data object
qtennis <- qdata(tennis, color = serve.speed, size = aces)
## then create plots
qhist(serve.speed, data = qtennis)
qbar(country, data = qtennis)
qscatter(first.serve.pts, second.serve.pts, data = qtennis)
qboxplot(~points + first.serve.pts + second.serve.pts, data = qtennis)
# all variables; you may need a large window
qparallel(~., data = qtennis, names = names(tennis), horizontal = TRUE)
record_selector(name, data = qtennis) # a simple GUI to show the names
cranvas_off()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.