adschai at optonline.net
2007-May-26 19:20 UTC
[R] How to assign RODBC object as R class slots and method signature
HiI have a class which would like to hold a connection to ODBC data connection. The handle to the connection is something like (according to RODBC manual):channel = odbcConnect("DSN",uid="user",pwd="password")However, I would like to make a slot of my "foo" class to hold this object. For example:setClass("foo", representation(channel="RODBC"))But this won't compile as it keeps saying that it cannot find "RODBC" as a valid class name even I have the package loaded in place. And from what I found in RODBC manual, the 'channel' variable should be of type 'RODBC'. This makes it even more difficult when I try define this database connection like 'channel' above as method signature.For example, I have a class for method like this.setMethod("setConn", "foo", signature(object="foo",newconn="RODBC") function(object, newconn) { ... do something here. })This doesn't compile. It will keep saying that it doesn't know about type "RODBC". Please let me know how we can solve this? Thank you.- adschai [[alternative HTML version deleted]]