[Rd] S4 default for coercing

Paul Gilbert pgilbert at bank-banque-canada.ca
Wed Apr 23 17:01:21 CEST 2008

Something has changed in the S4 default for coercing.  Am I now suppose 
to use setAs, or is there something else I should do  to make this work:

R version 2.7.0 (2008-04-22)
 > require("methods")
 > setClassUnion("OptionalPOSIXct",   c("POSIXct",   "NULL"))
[1] "OptionalPOSIXct"
 > setClass("TSmetax",
   representation(serIDs="character", ExtractionDate="OptionalPOSIXct" ))
[1] "TSmetax"
 > setGeneric("TSmetax", def= function(x, ...) standardGeneric("TSmetax"))
[1] "TSmetax"
 > setMethod("TSmetax",   signature(x="character"),  definition= 
function(x, ...){
new("TSmetax", serIDs=x, ExtractionDate=Sys.time())  } )
[1] "TSmetax"

 > z <- new("TSmetax", serIDs="whatever", ExtractionDate= Sys.time())
Error in as(slotVal, slotClass, strict = FALSE) :
  no method or default for coercing "POSIXt" to "OptionalPOSIXct"

(It did work in R-2.6.2.)


La version française suit le texte anglais.


This email may contain privileged and/or confidential in...{{dropped:26}}

More information about the R-devel mailing list