This function is generic (see Methods); method functions can be written to handle specific classes of data. Classes which already have methods for this function include:
crystal.list, crystal.vector, decompose.
dotchart(data, labels=<<see below>>, groups=NULL, gdata=NULL, horiz=T,
pch="o", lty=2)
Graphical parameters may also be supplied as arguments to this function (see par). In addition, the high-level graphics arguments described under par and the arguments to title may be supplied to this function.
# a simple function to make dotcharts from matrices with dimnames
dotchart.mat <- function(mat, col.is.main = T, ...)
{
if(col.is.main)
mat <- t(mat)
g.lab <- dimnames(mat)[[2]]
if(length(g.lab))
g <- factor(col(mat), labels = g.lab)
else g <- factor(col(mat))
la.lab <- dimnames(mat)[[1]]
if(length(la.lab))
la <- factor(row(mat), labels = la.lab)
else la <- factor(row(mat))
dotchart(mat, labels = la, groups = g, ...)
invisible()
}
perc.data <- c(5.4, 3.1, 3.5, 5.7, 8.6, 25.0, 20.4,
26.0, 22.0, 36.3, 34.1, 28.0, 14.4, 11.4, 4.5)
percent <- matrix(perc.data,ncol=3, byrow=T)
community <- c("Old Suburb", "Coast County", "New Suburb")
service <- c("Child Care", "Health Services",
"Community Centers", "Family & Youth", "Other")
com <- factor(col(percent), label=community)
serv <- factor(row(percent), label=service)
dotchart(percent, labels=com, group=serv)
dotchart(percent, labels=serv, group=com, horiz=F)
# now plot the same thing with the median percent for each service
gmed <- tapply(percent, com, median)
dotchart(percent, labels=serv, group=com, gdata=gmed)