From pgilbert at bank-banque-canada.ca  Wed Apr 23 17:01:21 2008
From: pgilbert at bank-banque-canada.ca (Paul Gilbert)
Date: Wed, 23 Apr 2008 11:01:21 -0400
Subject: [Rd] S4 default for coercing
Message-ID: <480F4F41.3030806@bank-banque-canada.ca>

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.)

Paul
====================================================================================

La version fran?aise suit le texte anglais.

------------------------------------------------------------------------------------

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



[Rd] S4 default for coercing
Paul Gilbert