Skip to content

(PR#9589) 'union' does not handle factors while 'intersect'

1 message · Brian Ripley

#
This is not a bug, nor is the subject line true: both do accept 
factors but what they do with factors is undocumented.  From the help 
(not 'man') page

      Performs *set* union, intersection, (asymmetric!) difference,
      equality and membership on two vectors.
                                     ^^^^^^^
so it is not said to work on factors.  I disagree that what intersect() 
for factors does is 'sensible': e.g. it is asymmetric in its arguments.

The 'standard' behaviour would be for R to coerce arguments to whatever 
they are documented to be, here using as.vector, and we will consider 
doing that.
On Thu, 29 Mar 2007, prechelt at inf.fu-berlin.de wrote:

            
Indeed, it excludes them as valid inputs.