Stem and leaf plots
Base R function stem()
The stem() function produces a simple
stem and leaf plot:
- stem(urb) stem and leaf plot of span class="varnam">urb.
- stem(urb, scale=2) the scale=
(default 1) modifies the length of the stem and leaf plot, for instance a value of 2, will produce
a stem-and-leaf plot that is roughly twice as long as with the default of 1.
- width= modifies the width of the stema-and-leaf plot.
- stem(log10(urb)) stemplot of logged urb.
apply(world,2,stem)
Produces a stemplot for each variable (column) of the data frame world.
[Details on apply()]
by(urb,continent,stem)
produces a stemplot of urb for each continent.
[Details on by()]
stem.leaf() {aplpack}
Hans Peter Wolf (University of Bielefeld) has developped a more refined version
stem.leaf() available in package is available in library aplpack, offering much more control,
producing HI/LO stems showing outliers whenever present. Back to back stemleaves are also available.
- stem.leaf(gnpcap) Stem leaf plot
- stem.leaf.backback(lifeem,lifeef) Back to back stem and leaf plot.
- stem.leaf.backback(lifeem,lifeef,back.to.back=FALSE) Two parallel stem and leaf plots
- stem.leaf(gnpcap, style="bare", depths=FALSE) Different style, does not show depths; different style (default "Tukey")
- stem.leaf(gnpcap, rule.line="Velleman") Number of lines =2*sqrt(n) instead of default "Dixon" = 10*log10(n) or "Sturges" = 1 + log2(n)
- stem1<-stem.leaf(gnpcap) invisibly returns a list of elements, including lower , and
upper(list of observation on the low and high stem).
{aplpack} has also a slider.stem.leaf to build stem and leaf plots interactively.