Skip to content
Prev 59956 / 398502 Next

Testing for S4 objects

Dear Martin,

As it turns out, the test that I proposed (i.e., testing for NULL slotNames)
sometimes fails. For example:
character(0)

The following, however, seems to work (at least as far as I've been able to
ascertain):

isS4object <- function(object) length(slotNames(object)) != 0

I hope that this is a more robust test.

John

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