Learn R Programming

aplpack (version 1.3.3)

stem.leaf: stem and leaf display and back to back stem and leaf display

Description

Creates a classical ("Tukey-style") stem and leaf display / back-to-back stem and leaf display.

Usage

stem.leaf(data, unit, m, Min, Max, rule.line = c("Dixon", "Velleman", "Sturges"),
    style = c("Tukey", "bare"), trim.outliers = TRUE, depths = TRUE,
    reverse.negative.leaves = TRUE, na.rm = FALSE, printresult = TRUE)
stem.leaf.backback(x,y, unit, m, Min, Max, rule.line = c("Dixon", "Velleman", 
    "Sturges"), style = c("Tukey", "bare"), trim.outliers = TRUE, 
    depths = TRUE, reverse.negative.leaves = TRUE, na.rm = FALSE,
    printresult=TRUE, show.no.depths = FALSE, add.more.blanks = 0,
    back.to.back = TRUE)

Arguments

data

a numeric vector of data

x

first dataset for stem.leaf.backback

y

first dataset for stem.leaf.backback

unit

leaf unit, as a power of 10 (e.g., 100, .01); if unit is missing unit is choosen by stem.leaf.

m

number of parts (1, 2, or 5) into which each stem will be separated; if m is missing the number of parts/stem (m) is choosen by stem.leaf.

Min

smallest non-outlying value; omit for automatic choice.

Max

largest non-outlying value; omit for automatic choice.

rule.line

the rule to use for choosing the desired number of lines in the display; "Dixon" = 10*log10(n); "Velleman" = 2*sqrt(n); "Sturges" = 1 + log2(n); the default is "Dixon".

style

"Tukey" (the default) for "Tukey-style" divided stems; "bare" for divided stems that simply repeat the stem digits.

trim.outliers

if TRUE (the default), outliers are placed on LO and HI stems.

depths

if TRUE (the default), print a column of "depths" to the left of the stems; the depth of the stem containing the median is the stem-count enclosed in parentheses.

reverse.negative.leaves

if TRUE (the default), reverse direction the leaves on negative stems (so, e.g., the leaf 9 comes before the leaf 8, etc.).

na.rm

if TRUE "NA" values are removed otherwise the number of NAs are counted.

printresult

if TRUE output of the stem and leaf display by cat.

show.no.depths

if TRUE no depths are printed.

add.more.blanks

number of blanks that are added besides the leaves.

back.to.back

if FALSE two parallel stem and leaf displays are constructed.

Value

The computed stem and leaf display is printed out. Invisibly stem.leaf returns the stem and leaf display as a list containing the elements info (legend), display (stem and leaf display as character vecter), lower (very small values), upper (very large values), depths (vector of depths), stem (stem information as a vector), and leaves (vector of leaves).

Details

Unlike the stem function in the base package, stem.leaf produces classic stem-and-leaf displays, as described in Tukey's Exploratory Data Analysis. The function stem.leaf.backback creates back-to-back stem and leaf displays.

References

Tukey, J. Exploratory Data Analysis. Addison-Wesley, 1977.

See Also

stem

Examples

Run this code
# NOT RUN {
stem.leaf(co2)
stem.leaf.backback(co2[1:120],co2[121:240])
stem.leaf.backback(co2[1:120],co2[121:240], back.to.back = FALSE)
stem.leaf.backback(co2[1:120],co2[121:240], back.to.back = FALSE,
                   add.more.blanks = 3, show.no.depths = TRUE)
stem.leaf.backback(rivers[-(1:30)],rivers[1:30], back.to.back = FALSE, unit=10, m=5, 
                   Min=200, Max=900, add.more.blanks = 20, show.no.depths = TRUE)
# }

Run the code above in your browser using DataLab