>>>>> Martin Morgan <mtmor...@fredhutch.org> >>>>> on Thu, 4 Jun 2015 10:33:37 -0700 writes:
> On 06/04/2015 10:08 AM, cgenolin wrote: >> Hi the list, >> >> I have a variable y that is either NA or some S4 object. I would like to >> know in which case I am, but it seems taht is.na does not work with S4 >> object, I get a warnings: >> >> --- 8< ------------ >> setClass("myClass",slots=c(x="numeric")) >> if(runif(1)>0.5){a <- new("myClass")}else{a <- NA} >> is.na(a) >> --- 8< ------------ >> >> Any solution? > getGeneric("is.na") > shows that it's an S4 generic, so implement a method > setMethod("is.na", "myClass", function(x) FALSE) > Martin For the present special case though, a more efficient solution would be to use isS4(.) instead of !is.na(.) another Martin >> Thanks >> Christophe ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.