[R] length of S4

Christophe Genolini cgenolin at u-paris10.fr
Sat Mar 15 21:54:10 CET 2008


Hi the list,

With basic type, length gives the length of the vector
Wtih list, length gives the number of item
With S4 object, length gives...one. Even with an objet with empty slot.

setClass("E",representation(e="numeric"))
[1] "E"
 length(new("E"))
[1] 1
setClass("E",representation(e="matrix"))
[1] "E"
length(new("E"))
[1] 1

Is there a way to get the real length of an S4 objet ? Furthermore, is 
there a simple way to detect that an object is has all its slot to 
object of size zero ?

Thanks

Christophe



More information about the R-help mailing list