Hi,
Is there a simple package to manage sets of general objects, and perform
simple operations like:
- union
- intersection
- difference
- test for membership...
but where the equality test between 2 objects is under the control of the
programmer?
In the base package, it seems only operations on vectors are allowed.
And I tried also the sets package, with the cset class, but I did not manage
to make it work:
for example, if I want to manage sets of lists, where equality is predicated
on only one element (named id) of the list,
defining a:
obj.equal.p <- function(x,y){ x$id == y$id }
and then
FUN <- matchfun(obj.equal.p)
and then:
obj1 <- list(id=1,info="toto1")
obj2 <- list(id=2,info="toto2")
obj3 <- list(id=3,info="toto3")
cs <- cset(set(obj1,obj2,obj3), matchfun = FUN)
obj4 <- list(id=1,info="toto4") (yes, id=1)
obj4 %e% cs
returns a FALSE instead of the TRUE I was expecting since obj4$id =obj1$id.
Thanks for your help
Johnny
[[alternative HTML version deleted]]