Dear R gurus
I've a question concerning the transformation of a new S4 class
(that I defined) and the existing class "POSIXlt". I did the
following:
## Definition of the new class:
setClass("dtime",
representation(data = "POSIXlt"),
prototype(data = as.POSIXlt("2004/06/01")))
## Transformation between the new class "dtime" and
"POSIXlt":
setAs("dtime", "POSIXlt", def = function(from) {
from at data
})
setAs("POSIXlt", "dtime", def = function(from) {
new("dtime", data = from)
})
## Create a new "dtime" object:
(x1 <- new("dtime"))
str(x1)
## Transformation to "POSIXlt" class works well:
(y1 <- as(x1, "POSIXlt"))
str(y1)
## Transformation to "dtime" class fails
as(y2, "dtime")> Fehler in insertMethod(methods, sig, args, def, TRUE) :
inserting method into non-methods-list object (class "NULL")
## This works properly
new("dtime", data = y2)
####################################################################
## Now I put another setAs for the Subclass "POSIXt"
setAs("POSIXt", "dtime", def = function(from) {
new("dtime", data = from)
})
## and the transformation to "dtime" class works:
as(y2, "dtime")
I tried to understand what happend, without success. Could
someone give me a hint or a reference (some help page or others)
to improve my understanding, please?
Thank you very much.
I work with:
platform i686-pc-linux-gnu
arch i686
os linux-gnu
system i686, linux-gnu
status Under development (unstable)
major 2
minor 1.0
year 2005
month 03
day 22
language R
Regards,
Christoph Buser
--------------------------------------------------------------
Christoph Buser <buser at stat.math.ethz.ch>
Seminar fuer Statistik, LEO C11
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-5414 fax: 632-1228
http://stat.ethz.ch/~buser/