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

From: <>
Date: Fri 20 Aug 2004 - 02:14:06 EST

I didn't get any feedback on this posting,

so I will commit my proposal to recycle the coordinates (x,y) to the length of 'labels' if the latter is longer (instead of silently dropping the extra labels[] entries).

Martin Maechler

>>>>> "MM" == Martin Maechler <>
>>>>> on Tue, 13 Jul 2004 18:22:05 +0200 (CEST) writes:

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

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

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

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

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

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

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

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

    MM> Martin Maechler

    MM> ______________________________________________
    MM> mailing list     MM> mailing list Received on Fri Aug 20 02:24:05 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 08:59:20 EST