# [Rd] dotchart {graphics} 2.11.1 vs. 2.12.1 [followed up from Rhelp]

Joshua Wiley jwiley.psych at gmail.com
Tue Feb 1 20:00:07 CET 2011

```Dear List,

With the R 2.12.0 addition of table methods for points(), dotchart()
struggles with tables.  I found several possible solutions, but it is
beyond my skill to decide what is "best".  Here is a small example:

#############################################
x <- table(infert\$education)
y <- 1:3L

dotchart(x) # error about incorrect plot type

## moving closer to the cause, dotchart() essentially does
plot(x = c(0, 150), y = c(0, 5), type = "n")
points(x, y) # error, because arg #2 is the type

## One option would be to explicitly name the arguments in dotchart()
points(x = x, y = y) # "works", but misses the point (no pun intended)

## Another possibility would be to add unclass(). I'm not sure
## if this would have other repercussions.  line 71 could become:
points(unclass(x), y, pch = pch, col = color, bg = bg)

## Other options could be adding a method for dotchart()
## or to update the table method for points()
points.table <- function (x, y, type = "h", lwd = 2, ...)
{
if (length(dim(x)) == 1L) {
nx <- dimnames(x)[[1L]]
is.num <- suppressWarnings(!any(is.na(xx <- as.numeric(nx))))
x0 <- if (is.num)
xx
else seq.int(x)
if (missing(y)) {
points(x0, unclass(x), type = type, lwd = lwd, ...)
} else points(unclass(x), y, type = type, lwd = lwd, ...)
}
else stop("only for 1-D table")
}

plot(x = c(0, 150), y = c(0, 5), type = "n")
points(x, y, type = "p")

#############################################

--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

```