[R] test to see if a s4 property is assigned?

darckeen darckeen at hotmail.com
Thu Sep 16 23:23:44 CEST 2010


>
setClass("person",representation(age="numeric",weight="numeric"),prototype(age=NULL,weight=NULL))
[1] "person"
> bob <- new("person",age=30)
Error in validObject(.Object) : 
  invalid class "person" object: invalid object for slot "weight" in class
"person": got class "NULL", should be or extend class "numeric"

So I guess I can only protoype a property to NULL if its defined as ANY?  I
though there might be a way to test if a propery was assigned to get around
this.  Really kinda turns me off from S4 classes :\
-- 
View this message in context: http://r.789695.n4.nabble.com/test-to-see-if-a-s4-property-is-assigned-tp2541044p2542958.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list