R: add a membership class

Mainly because the compare S3 generic for default interferes with
testthat, that also has a compare S3 generic.