[Rd] text(x, y, labels) - recycling problems and RFC (PR#7084)
maechler at stat.math.ethz.ch
maechler at stat.math.ethz.ch
Fri Aug 20 15:05:07 CEST 2004
>>>>> "BDR" == Prof Brian Ripley <ripley at stats.ox.ac.uk>
>>>>> on Thu, 19 Aug 2004 17:50:13 +0100 (BST) writes:
BDR> On Thu, 19 Aug 2004 maechler at 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 at 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 at stat.math.ethz.ch mailing list
MM> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
>>
>> ______________________________________________
>> R-devel at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
BDR> --
BDR> Brian D. Ripley, ripley at 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 at stat.math.ethz.ch mailing list
BDR> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list