I have some troubles getting a class from an older packages been recognized by the S4 class definition. I keep on getting the error
Error in makePrototypeFromClassDef(properties, ClassDef, immediate, where) :
in making the prototype for class "Tsvmm" elements of the prototype failed to
match the corresponding slot class: dates (class "dates" )
In addition: Warning message:
undefined slot classes in definition of "Tsvmm": dates(class "dates")
A reproducible example:
require(chron)
setClass(
Class="Tsvmm",
representation=representation(
data = "data.frame",
dates = "dates"
),
prototype=prototype(
data = data.frame(),
dates = chron(0)
)
)
When trying class(chron(0))
, the answer is "dates" "times"
. using is.numeric(chron(0))
, the answer is TRUE
. Yet, when I set the class of slot dates as "numeric"
, I get the same error without the warning message.
I have the feeling I'm overlooking something obvious, but I couldn't find it in the documentation yet. Anybody any pointers?
PS: I know the chron
package is at least peculiar, but I have good reasons to use this. Plus, the problem is likely to occur with other packages. See this as an example for a general question. So please, don't tell me to use the Date or POSIXt classes. That's a hack I'm using now.
It seems that you need setOldClass to make methods believe dates is a real class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With