6

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"
  )                    
)

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?

John Paul
  • 12,196
  • 6
  • 55
  • 75
Kyle Brandt
  • 26,938
  • 37
  • 124
  • 165

1 Answers1

7

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.

Kyle Brandt
  • 26,938
  • 37
  • 124
  • 165
  • It will not work when I use roxygen2 to document it. If I put `setOldClass("RODBC")` into a single file. When checking, it will be "the specification for S3 class “dist” in package seems equivalent to one from package ‘graph’: not turning on duplicate class definitions for this class." – Zhilong Jia Mar 06 '15 at 14:53