施主这是何苦呢？
class(obj) == 'foo' is bad, because obj may have multiple classes; as.factor() does the job perfectly here