MichaelChirico / r-bugs

A ⚠️read-only⚠️mirror of https://bugs.r-project.org/
20 stars 0 forks source link

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

Open MichaelChirico opened 4 years ago

MichaelChirico commented 4 years ago

From: Martin Maechler <maechler@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>> 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


METADATA

MichaelChirico commented 4 years ago

From: Martin Maechler <maechler@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>> 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@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>>
>>>>     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@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::> mailing list
MM> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel

METADATA

MichaelChirico commented 4 years ago

From: Prof Brian Ripley <ripley@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>> On Thu, 19 Aug 2004 maechler@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::> 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@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>>
>>>>>     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@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::> mailing list
MM> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel

______________________________________________
R-devel@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::> mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

-- Brian D. Ripley, ripley@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ <CENSORING FROM DETECTED PHONE NUMBER ONWARDS; SEE BUGZILLA>


METADATA

MichaelChirico commented 4 years ago

From: Martin Maechler <maechler@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>>

>>>> "BDR" == Prof Brian Ripley <ripley@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>>
>>>>     on Thu, 19 Aug 2004 17:50:13 +0100 (BST) writes:
BDR> On Thu, 19 Aug 2004 maechler@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::> 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@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>>
> >>>>>     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@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::> mailing list
MM> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
> 
> ______________________________________________
> R-devel@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 
BDR> -- 
BDR> Brian D. Ripley,                  ripley@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>
BDR> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/

<CENSORING FROM DETECTED PHONE NUMBER ONWARDS; SEE BUGZILLA>


METADATA

MichaelChirico commented 4 years ago

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


METADATA

MichaelChirico commented 4 years ago

This discussion seems to have stopped in 2004, but the issue of not recycling still present. It looks like there was a discussion about a possible warning and maybe there was never a resolution of that discussion. Could it be fixed? It does seem inconsistent.


METADATA