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

From: <>
Date: Fri 20 Aug 2004 - 23:05:07 EST

>>>>> "BDR" == Prof Brian Ripley <> >>>>> on Thu, 19 Aug 2004 17:50:13 +0100 (BST) writes:

    BDR> On Thu, 19 Aug 2004 wrote:
>> 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).

    BDR> I'd suggest only doing non-fractional recycling (or at the very least 
    BDR> warning against fractional recycling).  I would expect almost all 
    BDR> occurrences of your example would be unintended.

well, as said, both "grid" and S-plus do recycle (w/o warning) in this situation.

Do we have precedence cases of "recycling but warn if fractional" ?


>> >>>>> "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
    BDR> -- 
    BDR> Brian D. Ripley,        
    BDR> Professor of Applied Statistics,
    BDR> University of Oxford,             Tel:  +44 1865 272861 (self)
    BDR> 1 South Parks Road,                     +44 1865 272866 (PA)
    BDR> Oxford OX1 3TG, UK                Fax:  +44 1865 272595

    BDR> ______________________________________________
    BDR> mailing list     BDR> mailing list Received on Fri Aug 20 23:07:56 2004

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