[R] is.empty for formal class object

Gordon Smyth smyth at wehi.edu.au
Sat Mar 1 02:21:03 CET 2003


I'd like to construct a function is.empty(x) which would work on arbitrary 
objects, and would tell me whether the object contains any data. I think 
that I can write a function which will recurse down through all the slots 
of x (and slots of slots) until it reaches objects of elementary type 
(NULL, character, numeric, logical, matrix, function, data.frame and 
possibly others) and then tests for length zero or nullness.

But does such a function already exist? Or is there a cleverer or more 
direct way to do it?

I've looked through the online help for the methods package, and I've done 
a keyword search through the R help for "empty" without finding something 
that looks relevant.

Thanks
Gordon




More information about the R-help mailing list