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

darckeen darckeen at hotmail.com
Fri Sep 17 15:51:57 CEST 2010


>
setClass("person",representation(name="character",age="numeric",kids="list"))
[1] "person"
> bob <- new("person")
> length(bob at name)
[1] 0
> length(bob at age)
[1] 0
> length(bob at kids)
[1] 0
> is.na(bob at kids)
logical(0)
> is.na(bob at age)
logical(0)
> is.na(bob at name)
logical(0)
> bob at kids <- list("joe","sue")
> is.na(bob at kids)
[1] FALSE FALSE
> length(bob at kids)
[1] 2

Ah, length(object at property) is what i was looking for.  Thanks alot.
-- 
View this message in context: http://r.789695.n4.nabble.com/test-to-see-if-a-s4-property-is-assigned-tp2541044p2543895.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list