Re: [R] Hook into Coercion Framework for data.frame

From: Erich Neuwirth <erich.neuwirth_at_univie.ac.at>
Date: Tue, 26 Apr 2011 22:16:30 +0200

statconnDCOM, availagble from rcom.univie.ac.at is a (D)COM server accessing R.
rcom (available from CRAN) is an R package which can turn R into a COM server or into a COM client.

These tools have their own mailing list which can be subscribed at rcom.univie.ac.at.

On 4/26/2011 6:20 PM, Von Der Hirschheydt, Juergen wrote:
> Hi,
>
> I am looking into a way to hook into the R coercion framework to allow
> me to convert table-like data stored within a COM object into a
> data.frame.
>
> Some of our COM objects have their own table-like data storage, and from
> R's point of view it's an object (EXTPTRSXP) decoarated with a sepcial
> symbol so we can easily identify it.
>
> COM_Table <- a_method_that_creates_the_object()
> class(COM_TABLE)
> > "QS.IpdgRelation"
>
> In addition, we have a method that transforms this object into a
> data.frame:
>
> relation.to.data.frame <- function(obj) { ... }
>
> A user can easily transform the above object into a data.frame by
> calling:
>
> myDataFrame <- relation.to.data.frame(COM_Table)
>
> That all works nice and well, but we'd like to take it a step further
> and be able to call
>
> data.frame(COM_Table) and/or
> as.data.frame(COM_Table)
>
> To achieve the same coercion. I've tried to hook into the coercion by
> using setAs :
>
> setOldClass ( "QS.IpdgRelation" )
> setAs ( "QS.IpdgRelation", "data.frame", function(from)
> relation.to.data.frame(from) )
>
> Which allows me to do
>
> as ( COM_Table, "data.frame" )
>
> But I can't seem to get the last step to hook this coercion into the
> data.frame() or as.data.frame() call. Is there a way to achieve this, or
> am I chasing a red hering here ?
>
> Any help appreciated,
> Thanks a lot,
>
> Juergen
>
> ===============================================================================
> Please access the attached hyperlink for an important el...{{dropped:4}}
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 26 Apr 2011 - 20:19:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 26 Apr 2011 - 20:20:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive