[Rd] text(x, y, labels) - recycling problems and RFC (PR#7084)

maechler at stat.math.ethz.ch maechler at stat.math.ethz.ch
Tue Jul 13 18:22:05 CEST 2004


Not a bug necessarily, in text(), but at least an inconsistency,
and a need for more documentation:  Contrary to e.g., plot(),
text(x,y,labels) *does* recycle it's arguments to some extent --
and probably has always in S.

However it doesn't do all I think it should, i.e.,

 plot(1:7); text(1:2, 1+ 1:3, LETTERS[1:4])

does recycle 'x' to c(1:2, 1) {length 3} to match 'y'
but doesn't recycle to length 4 in order to match 'labels'.

While one can well accept this, I believe it should give a
warning since it silently 'drops' the "d".

However, I'm proposing to consider S(-plus) compatibility here.
In S-PLUS 6.1, the result of the above is
identical to
    plot(1:7); text(rep(1:2,length=4), rep(1+ 1:3, length=4), LETTERS[1:4])
i.e. (x,y) is recycled to length 4, the length of 'labels'.
					
Further note that in
    plot(1:7); text(1:2, 1+ 1:3, LETTERS[1:2], col=2:6)
the 'labels' *are* recycled to length 3, matching (x,y) -- but
not to length 5 of 'col' which is fine -- just not the other way around.

I'd propose that R should recycle all three (x,y,labels)
[but not more] to common length.

BTW, "grid" graphics do recycle as well, at least  
grid.text(labels, x, y) does --- and as I see it does also
recycle at least the 'rotation'.

Martin Maechler



More information about the R-devel mailing list