Skip to content
Prev 4110 / 21312 Next

[Bioc-devel] why doesn't this ``just work'' ? (defined coercion is ignored by S3 method?)

Hi Tim,
On 02/26/2013 02:01 PM, Tim Triche, Jr. wrote:
What seems to be called internally is as.data.frame.default, and
of course as.data.frame.default as no idea how to convert a DataFrame
into a data.frame:

   > as.data.frame.default(DataFrame())
   Error in as.data.frame.default(DataFrame()) :
     cannot coerce class "structure("DataFrame", package = "IRanges")" 
to a data.frame

I think this would work if you defined an S3 as.data.frame method
for DataFrame, instead of an S4 "coerce" method from DataFrame to
data.frame. Try to define the following:

   as.data.frame.DataFrame <- selectMethod("as.data.frame", "DataFrame")

A couple of months ago I've started to add some S3 methods to the
IRanges/GenomicRanges infrastructure. So far I only did it for
duplicated, unique, sort, levels, as.list, window, window<-. but
many are still missing (30-40 or more). as.data.frame.DataFrame is
one of them.

Cheers,
H.