在S4对象中使用S3类的示例 [英] Example of Using an S3 Class in a S4 Object

查看:144
本文介绍了在S4对象中使用S3类的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to include an RODBC connection as part of S4 object. It looks like RODBC is S3. For example:

setClass(
  Class="Node",
  representation=representation(
    nodeName = "character",
    connection = "RODBC"
  )                    
)

抛出undefined slot classes.看来我想使用setOldClass,但是我在弄清楚如何使用它时遇到了麻烦.假设我确实想要setOldClass,我将如何使用setOldClass,以便可以将RODBC连接包括为Node类的插槽?

Throws undefined slot classes. It looks like I want to use setOldClass, but I am having trouble figuring out how to use it. Assuming I do want setOldClass, How would I use setOldClass so that I can include my RODBC connection as slot to my Node class?

推荐答案

尽管此功能涉及了很多文档,但是如果您只需要在插槽中包含该类,那么它就很简单:

Although the documentation is quite involved for this function, if all you need to do include the class in a slot it is as simple as:

setOldClass("RODBC")

setClass(
  Class="Node",
  representation=representation(
    nodeName = "character",
    connection = "RODBC"
  )                    
)

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

This is also what you would use for reference classes.

这篇关于在S4对象中使用S3类的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆