Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Class 从S4类定义中的包识别S3(?)类_Class_R_Definition_S4 - Fatal编程技术网

Class 从S4类定义中的包识别S3(?)类

Class 从S4类定义中的包识别S3(?)类,class,r,definition,s4,Class,R,Definition,S4,从S4类定义识别的旧包中获取类时遇到一些问题。我不断地犯错误 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" )

从S4类定义识别的旧包中获取类时遇到一些问题。我不断地犯错误

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") 
一个可重复的例子:

require(chron)

setClass(
  Class="Tsvmm",
  representation=representation(
      data  = "data.frame",
      dates = "dates"
  ),
  prototype=prototype(
      data  = data.frame(),
      dates = chron(0)
  )
)
尝试
类(chron(0))
时,答案是
“日期”“时间”
。使用
is.numeric(chron(0))
,答案是
TRUE
。然而,当我将插槽日期的类别设置为
“numeric”
时,我得到了相同的错误,但没有警告消息

我有一种感觉,我忽略了一些显而易见的东西,但我还没有在文档中找到它。有人给我指点吗


PS:我知道
chron
软件包至少很特别,但我有充分的理由使用它。此外,其他软件包也可能出现此问题。请将此作为一般问题的示例。所以,请不要告诉我使用Date或POSIXt类。这是我现在正在使用的一个技巧。

似乎需要让方法相信dates是一个真正的类

我也遇到了类似的问题,因为Gtk2对象(例如Gtk2::GtkBuilder)不是S4类,而我希望在自己的代码中有这样一个对象的实例。我想我通过删除prototype()的东西并使用“initialize()”方法解决了这个问题