Add (S3) classes to an object

prepend_class(x, cls = character(0), null = list())

append_class(x, cls = character(0), null = list())

Arguments

x

The object whose class is to be updated.

cls

The class(es) to add.

null

If x is NULL, first replace it with this value, since NULL can't have a class.

Value

The object with new class structure.

Details

The new class vector will be uniquified, in left-to-right preferential order (so x,y,x,z becomes x,y,z).