[R] error in plot(table(c('a','a')))

R. Michael Weylandt michael.weylandt at gmail.com
Mon Nov 26 22:39:31 CET 2012


On Mon, Nov 26, 2012 at 2:41 PM, Ludo Pagie <l.pagie at nki.nl> wrote:
> Hi all,
>
> there appears to be something strange with the plotting of tables of 1
> dimension; if I attempt to make a plot of a table of characters with only
> 1 value I get an error (Error in xy.coords(x, y, xlabel, ylabel, log) :
>   'x' and 'y' lengths differ). With more than one value I don't get
> errors, neither with integers (even if only 1 value):
>
> tbl.char1 <- table(c('a','a'))
> tbl.char2 <- table(c('a','a','b'))
> tbl.int1 <- table(c(1,1))
>
> # error:
> plot(tbl.char1)
>
> # no errors:
> plot(tbl.char2)
> plot(tbl.int1)
>

Confirmed in current R-devel. It seems to arise from plot.table's use
of seq.int(x) when the dimnames of the table are not integers. I'm not
sure if this shouldn't be seq_along(x) instead, but I'm not sure I
totally follow the internal logic, so perhaps someone can offer second
opinion?

Michael




More information about the R-help mailing list