Bug 14638 - Wishlist: pmin/pmax silently recycle ragged input
Wishlist: pmin/pmax silently recycle ragged input
Status: CLOSED WISHLIST
Product: R
Classification: Unclassified
Component: Wishlist
R 2.13.0
ix86 (32-bit) Mac OS X v10.6
: P5 minor
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-07-22 21:50 UTC by Richard Bourgon
Modified: 2011-09-04 14:02 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 Richard Bourgon 2011-07-22 21:50:09 UTC
Recycling when one vector's length does not evenly divide into the other's is usually unintended. Most code throws a warning or an error:

  > 1:3 + 1:2
  [1] 2 4 4
  Warning message: 
  In 1:3 + 1:2 :
    longer object length is not a multiple of shorter object length

  > data.frame(a = 1:3, b = 1:2)
  Error in data.frame(a = 1:3, b = 1:2) : 
    arguments imply differing number of rows: 3, 2

The pmin() and pmax() functions recycle silently in such cases:

  > pmin(1:3, 1:2)
  [1] 1 2 1

It would be nice to get a warning here.
Comment 1 Brian Ripley 2011-07-27 20:34:54 UTC
This is not a bug.  Wishes should be marked as such (see the R FAQ).
Comment 2 Brian Ripley 2011-09-04 14:02:41 UTC
fulfilled for 2.14.0