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

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/stem.leaf.R

Description

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

Usage

1
2
3
4
5
6
7
8
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.

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.

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).

Author(s)

Peter Wolf, the code has been slightly modified by John Fox jfox@mcmaster.ca with the original author's permission, help page written by John Fox, the help page has been slightly modified by Peter Wolf.

References

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

See Also

stem

Examples

1
2
3
4
5
6
7
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)

Example output

Loading required package: tcltk
Warning message:
no DISPLAY variable so Tk is not available 
1 | 2: represents 12
 leaf unit: 1
            n: 468
    8    31* | 33344444
   70    31. | 55555556666666666666667777777777788888888888888899999999999999
  135    32* | 00000000000000001111111111112222222222222222333333333333444444444
  187    32. | 5555555566666666677777777777777778888888889999999999
  233    33* | 0000000011111111112222222222233333333344444444
  (40)   33. | 5555556666666666777777777888889999999999
  195    34* | 000000011111112222222222233333334444444
  156    34. | 5555555566666666777777788888889999999
  119    35* | 00000111111122222222223333333333444444444
   78    35. | 555555555666666667777777788888899999999999999
   33    36* | 0000001111112222333333444444
    5    36. | 55566
_________________________________________________________________________________
  1 | 2: represents 12, leaf unit: 1 
                           co2[1:120]       co2[121:240]                     
_________________________________________________________________________________
                                     | 31* |                                     
    3                             333|   t |                                     
   15                    555555544444|   f |                                     
   41      77777777777666666666666666|   s |                                     
  (29)  99999999999999888888888888888| 31. |                                     
   50     111111111110000000000000000| 32* |1                                1   
   23              333333222222222222|   t |2222333333                      11   
    5                           55444|   f |444444555555                    23   
                                     |   s |6666666667777777777777777       48   
                                     | 32. |8888888889999999999            (19)  
                                     | 33* |000000001111111111              53   
                                     |   t |222222222223333333              35   
                                     |   f |4444444455                      17   
                                     |   s |6666777                          7   
                                     | 33. |                                     
                                     | 34* |                                     
_________________________________________________________________________________
n:                                120       120                              
_________________________________________________________________________________
_________________________________________________________________________________
  1 | 2: represents 12, leaf unit: 1 
       co2[1:120]                           co2[121:240]                          
_________________________________________________________________________________
  31* |                                    |                                     
    t |333                              3  |                                     
    f |444445555555                    15  |                                     
    s |66666666666666677777777777      41  |                                     
  31. |88888888888888899999999999999  (29) |                                     
  32* |000000000000000011111111111     50  |1                                1   
    t |222222222222333333              23  |2222333333                      11   
    f |44455                            5  |444444555555                    23   
    s |                                    |6666666667777777777777777       48   
  32. |                                    |8888888889999999999            (19)  
  33* |                                    |000000001111111111              53   
    t |                                    |222222222223333333              35   
    f |                                    |4444444455                      17   
    s |                                    |6666777                          7   
  33. |                                    |                                     
  34* |                                    |                                     
_________________________________________________________________________________
n:     120                                  120                                   
_________________________________________________________________________________
____________________________________________________________________________
  1 | 2: represents 12, leaf unit: 1 
       co2[1:120]                         co2[121:240]                       
____________________________________________________________________________
  31* |                                  |                                  
    t |333                               |                                  
    f |444445555555                      |                                  
    s |66666666666666677777777777        |                                  
  31. |88888888888888899999999999999     |                                  
  32* |000000000000000011111111111       |1                                 
    t |222222222222333333                |2222333333                        
    f |44455                             |444444555555                      
    s |                                  |6666666667777777777777777         
  32. |                                  |8888888889999999999               
  33* |                                  |000000001111111111                
    t |                                  |222222222223333333                
    f |                                  |4444444455                        
    s |                                  |6666777                           
  33. |                                  |                                  
  34* |                                  |                                  
____________________________________________________________________________
n:     120                                120                                
____________________________________________________________________________
___________________________________________________________________
  1 | 2: represents 120, leaf unit: 10 
      rivers[-(1:30)]                rivers[1:30]                  
                                     LO: 135                       
___________________________________________________________________
  2* |1111                          |0                             
   t |3333                          |                              
   f |455555                        |                              
   s |666677                        |                              
  2. |889                           |8889                          
  3* |00000111                      |1                             
   t |233                           |22233                         
   f |45555                         |5                             
   s |666677                        |                              
  3. |88899                         |9                             
  4* |11                            |0                             
   t |2222333                       |                              
   f |44                            |5                             
   s |667                           |6                             
  4. |9                             |                              
  5* |00                            |0                             
   t |2223                          |2                             
   f |44                            |                              
   s |67                            |                              
  5. |                              |                              
  6* |0011                          |00                            
   t |223                           |                              
   f |5                             |                              
   s |7                             |                              
  6. |89                            |                              
  7* |1                             |                              
   t |2233                          |3                             
   f |                              |                              
   s |6                             |                              
  7. |8                             |                              
  8* |0                             |                              
   t |                              |                              
   f |5                             |4                             
   s |                              |7                             
  8. |                              |9                             
  9* |00                            |0                             
___________________________________________________________________
      HI: 981 1038 1054 1100 1171    HI: 1000 1243 1450 1459       
      1205 1270 1306 1770 1885                                     
      2315 2348 2533 3710                                          
n:    111                            30                            
___________________________________________________________________

aplpack documentation built on Sept. 30, 2021, 5:08 p.m.

Related to stem.leaf in aplpack...