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

From: <maechler_at_stat.math.ethz.ch>
Date: Wed 14 Jul 2004 - 02:22:05 EST


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



R-devel@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel Received on Wed Jul 14 02:29:03 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:45:02 EST