[R] Testing for S4 objects

John Fox jfox at mcmaster.ca
Fri Nov 26 04:28:50 CET 2004


Dear r-help list members,

Is there a way to test whether an object is an S4 object? The best that I've
been able to come up with is

	isS4object <- function(object) !(is.null(slotNames(object)))

which assumes that an S4 object has at least one slot. I think this is safe,
but perhaps I'm missing something.

Thanks,
 John

--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox




More information about the R-help mailing list