在S4对象中使用S3类的示例

Kyl*_*ndt 6 methods r s4

我想包含一个RODBC连接作为S4对象的一部分.看起来RODBC是S3.例如:

setClass(
  Class="Node",
  representation=representation(
    nodeName = "character",
    connection = "RODBC"
  )                    
)
Run Code Online (Sandbox Code Playgroud)

投掷undefined slot classes.它看起来像我想使用setOldClass,但我无法弄清楚如何使用它.假设我确实想要setOldClass,我将如何使用setOldClass以便将RODBC连接作为插槽添加到我的Node类中?

Kyl*_*ndt 7

虽然这个函数非常涉及文档,但是如果你需要做的只是将类包含在一个插槽中,它就像这样简单:

setOldClass("RODBC")

setClass(
  Class="Node",
  representation=representation(
    nodeName = "character",
    connection = "RODBC"
  )                    
)
Run Code Online (Sandbox Code Playgroud)

这也是您用于参考类的内容.