# demonstrate stem and leaf diagrams
#
# Note that R has a built-in function called
# stem() but the output of that doees not correspond
# to the style generally accepted in this course.
# To remedy that situation you have a function
# called stem_leaf() in your desktop folder.
# first generate the data needed. Load the function
source("../gnrnd4.R")
# then use the function
gnrnd4(579043502, 4800321)
L1
# bring the stem_leaf function into the
# environment
source( "../stem_leaf.R")
# and run it with our data
stem_leaf( L1 )
# check out a histogram of the same data
hist( L1, breaks=5 )
abline(h=seq(0,15,5), lty="dashed", col="darkgrey")
# This is
# almost the same! Why the difference? Why
# does the stem and leaf show 6 values in the
# 340's and the histogram shows 5?
#
# That is a consequence of the histogram having
# a default setting of being "closed on the right".
# Therefore the data value "340" is counted in
# the 330-340 rectangle. We can change that with
# the setting right=FALSE.
hist( L1, breaks=5, right=FALSE)
abline(h=seq(0,15,5), lty="dashed", col="darkgrey")
# The only other thing that the stem and leaf
# gives us is the sorted list of the data. But
# we get that from
sort(L1)