#*****************************************************************************80
#
## chain_letter_dendrogram makes a dendrogram from a distance matrix.
#
# Students were given 11 chain letters. Each student was asked to pick
# a particular chain letter, and then estimate its "distance" from all
# the chain letters, using a particular scoring system.
#
# The results are here assembled into a distance matrix, from which a
# hierarchical clustering can be made and displayed.
#
# The distances were based on comparing positions in thw chain letters where
# a proper name occurred.
#
# "New England" 0 if the same, 1 otherwise.
# "R.A.F.Officer" 0 if the same, 1 otherwise.
# "Gene Welch" 0 if the same, 1 if one name different, 2 if both different.
# "Saul de Groda" 0 if the same, 1, 2 or 3 if 1, 2 or 3 names different or added.
# "Constantine Dias" 0 if the same, 1 or 2 if 1 or 2 names different.
# "Carlos Daddit" 0 if the same, 1 or 2 if 1 or 2 names different.
# "Dalan Fairchild" 0 if the same, 1 or 2 if 1 or 2 names different.
# "a young woman in California" 0 if both letters have or don't have this part,
# 5 if one does and one doesn't.
#
# The distance between the two chain letters is the sum of the 8 scores.
#
# From the distance matrix, we can compute a dendrogram that suggests,
# based on similarity, a sort of genealogy for the chain letters.
#
# Licensing:
#
# This code is distributed under the GNU LGPL license.
#
# Modified:
#
# 02 September 2020
#
# Author:
#
# John Burkardt
#
cat ( date ( ), "\n" )
cat ( "\n" )
cat ( "chain_letter_dendrogram\n" )
cat ( " ", version$version.string, "\n" )
cat ( " Construct a dendrogram to analyze the relationship\n" )
cat ( " among a set of 11 versions of a chain letter.\n" )
filename = "chain_letter_data.txt"
dist <- read.table ( filename, header = FALSE )
cat ( "\n" )
cat ( " Chain letter distance matrix read from '", filename, "'\n" )
dist <- as.dist ( dist )
hc <- hclust ( dist )
filename = "chain_letter_dendrogram.png"
png ( filename )
plot ( hc,
labels = c ( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'),
main = "Dendrogram for 11 chain letters A=1 through K=11" )
grid ( )
cat ( ' Graphics saved as "', filename, '"\n' )
#
# Terminate.
#
cat ( "\n" )
cat ( "chain_letter_dendrogram:\n" )
cat ( " Normal end of execution.\n" )
quit ( )