Bug 7084 - text(x, y, labels) - recycling problems and RFC
Summary: text(x, y, labels) - recycling problems and RFC
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Graphics (show other bugs)
Version: old
Hardware: All All
: P5 normal
Assignee: Jitterbug compatibility account
URL:
Depends on:
Blocks:
 
Reported: 2004-07-13 21:21 UTC by Jitterbug compatibility account
Modified: 2004-08-20 18:04 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jitterbug compatibility account 2004-07-13 21:21:57 UTC
From: Martin Maechler <maechler@stat.math.ethz.ch>
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

Comment 1 Jitterbug compatibility account 2004-08-19 21:13:56 UTC
From: Martin Maechler <maechler@stat.math.ethz.ch>
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 <maechler@stat.math.ethz.ch>
>>>>>     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> R-devel@stat.math.ethz.ch mailing list
    MM> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel

Comment 2 Jitterbug compatibility account 2004-08-19 21:50:13 UTC
From: Prof Brian Ripley <ripley@stats.ox.ac.uk>
On Thu, 19 Aug 2004 maechler@stat.math.ethz.ch 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).

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


> 
> Martin Maechler
> 
> >>>>> "MM" == Martin Maechler <maechler@stat.math.ethz.ch>
> >>>>>     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> R-devel@stat.math.ethz.ch mailing list
>     MM> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


Comment 3 Jitterbug compatibility account 2004-08-20 18:04:51 UTC
From: Martin Maechler <maechler@stat.math.ethz.ch>
>>>>> "BDR" == Prof Brian Ripley <ripley@stats.ox.ac.uk>
>>>>>     on Thu, 19 Aug 2004 17:50:13 +0100 (BST) writes:

    BDR> On Thu, 19 Aug 2004 maechler@stat.math.ethz.ch 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" ?

Martin

    >> >>>>> "MM" == Martin Maechler <maechler@stat.math.ethz.ch>
    >> >>>>>     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> R-devel@stat.math.ethz.ch mailing list
    MM> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
    >> 
    >> ______________________________________________
    >> R-devel@stat.math.ethz.ch mailing list
    >> https://stat.ethz.ch/mailman/listinfo/r-devel
    >> 
    >> 

    BDR> -- 
    BDR> Brian D. Ripley,                  ripley@stats.ox.ac.uk
    BDR> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
    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> R-devel@stat.math.ethz.ch mailing list
    BDR> https://stat.ethz.ch/mailman/listinfo/r-devel

Comment 4 Jitterbug compatibility account 2004-09-01 02:54:32 UTC
Audit (from Jitterbug):
Fri Aug 20 00:46:57 2004	paul	resent 7084.reply.1
Tue Aug 31 21:54:32 2004	ripley	moved from incoming to Graphics