Description Usage Arguments Details Value Author(s) See Also Examples
Draw an interactive histogram or spine plot based on a continuous variable,
optionally split by a categorical variable. It supports some common keyboard
interactions (see common_key_press
) as well as other
interactions specific to histograms and spine plots.
1 2 3 4 5 |
x |
the name of the numeric variable to be used to draw the histogram or spine plot |
bins |
the desired number of bins, default=30, overridden by binwidth if provided |
binwidth |
the bin width ( |
breaks |
sets break points, mostly for use with the tour |
ybreaks |
sets vertical axis, mostly for use with the tour |
freq |
draw the frequencies ( |
spine |
if |
... |
arguments passed to |
data |
a mutaframe created by |
main |
the main title |
horizontal |
|
xlim |
a numeric vector of length 2 (like |
ylim |
y-axis limits; similar to |
xlab |
x-axis title |
ylab |
y-axis title |
The splitting variable is usually specified in qdata
as the
color
or border
argument; if it is present, each bar in the
plot will be split into categories.
Arrow keys can be used to change the binwidth as well as the breakpoints in the plot. Up and Down can increase and decrease the binwidth respectively; Left and Right can move the breakpoints of the bins to the left (smaller) or right (larger). Mouse wheel helps zoom in/out of the plot.
In the identify mode, the breakpoints of the bin(s) as well as counts and proportion of cases in the bin(s) are shown as text labels in the plot.
The function qspine
is a short-hand version of qhist(...,
spine = TRUE)
.
A histogram or a spine plot
Yihui Xie <http://yihui.name>
Other plots: qbar
; qboxplot
;
qdensity
; qmval
;
qparallel
; qtime
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | library(cranvas)
#### (1) split histogram by species, and categorical linking
data(flea, package = "tourr")
qflea <- qdata(flea, color = species)
qhist(tars1, data = qflea)
## Use the up/down arrows to change binwidth, or the vertical bars on screen
## Right/left arrows change minimum bin (anchor) value
qhist(tars2, data = qflea, freq = FALSE, main = "density of tars2")
qhist(aede1, data = qflea, ylim = c(0, 10), main = "fix y-axis limits")
qhist(head, data = qflea, horizontal = TRUE)
qspine(aede2, data = qflea)
qparallel(~., data = qflea) # all variables
id <- link_cat(qflea, "species") # linking by categorical variable
## now brush one bar, all fleas of the same species will be brushed
## remove linking
remove_link(qflea, id)
#### (2) tennis data: without a splitting variable
qtennis <- qdata(tennis, color = "white", border = "black")
qhist(first.serve.pct, data = qtennis)
qbar(matches, data = qtennis)
qspine(matches, data = qtennis)
qhist(first.serve.pct, data = qtennis, horizontal = TRUE)
qhist(serve.speed, data = qtennis)
qhist(serve.speed, data = qtennis, freq = FALSE) # density
#### see help(wages) for yet another example
cranvas_off()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.