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

prechelt at inf.fu-berlin.de prechelt at inf.fu-berlin.de
Thu Mar 29 10:55:40 CEST 2007


Full_Name: Lutz Prechelt
Version: 2.4.1
OS: Windows XP
Submission from: (NULL) (160.45.111.67)


'union' ignores the fact if its arguments are factors while all other set
operations (intersect, setdiff, setequal, is.element) treat them sensibly.
The manpage does not even mention the term 'factor'.

Example:
f1=factor(c("a","b","b","c"));
f2=factor(c("a","d","d","e"));
print(union(f1,f2));
print(intersect(f1,f2));
print(setdiff(f1,f2));
print(setequal(f1,f2));
print(is.element(f1,f2))

prints

[1] 1 2 3
[1] a
Levels: a d e
[1] b c
Levels: a b c
[1] FALSE
[1]  TRUE FALSE FALSE FALSE



More information about the R-devel mailing list