class(x) class(x) <- value unclass(x)
unclass returns x, with all of its original attributes except its class, if any.
Functions may use unclass in order to deal with an object in raw form without any assistance from methods that may be available to process that class.
Assigning a class to an object is a primitive operation. Assigning class "matrix" to object x, for example, does not cause x to be coerced to have all the attributes of a matrix object: if you wanted that to happen, use as.matrix(x). Similarly, class is not a generic function and methods cannot be written for it.
foo <- list(a= letters[1:10], b= LETTERS[1:10]) class(foo) <- "example" unclass(foo) #prints foo without attribute "class"class(diag(3)) # returns NULL data.class(diag(3)) # returns "matrix"