Re: [Rd] R-2.15.0 and Exporting Methods Converted To S4 Generic

From: Martin Morgan <mtmorgan_at_fhcrc.org>
Date: Fri, 13 Apr 2012 06:05:57 -0700

On 04/13/2012 01:40 AM, Uwe Ligges wrote:
> You have to export the new generic as well.

that's not correct.

>
> Uwe Ligges
>
>
> On 12.04.2012 20:41, Roebuck,Paul L wrote:
>> Late to the show on this release, unfortunately.
>> One of our production packages no longer builds under R-2.15.0
>> with the following message.
>>
>> ** testing if installed package can be loaded
>> Error: Function found when exporting methods from the namespace
>> 'SuperCurve' which is not S4 generic: 'image'
>>
>>
>> Possibly relevant clues follow:
>>
>> ## From R/AllGenerics.R
>> if (!isGeneric("image")) {
>> setGeneric("image",
>> function(x, ...) standardGeneric("image"))
>> }

I think this paradigm is left over from an earlier time; at the time of package installation you know that your namespace has access to graphics::image, and that graphics::image is not an S4 generic. Also, your intention is to make an S4 generic without changing the signature. So just

setGeneric("image")

though the more explicit setGeneric is not incorrect, and the conditional promotion shouldn't be incorrect either.

>>
>> We have done the same for many S3 generics, converting them
>> to S4 and adding specific method-combinations as such...
>>
>> ## From various other R files...
>> setMethod("image", signature(x="RPPA"), ...
>> setMethod("image", signature(x="RPPADesign"), ...
>>
>> And then exported them for use outside the package.
>>
>> ## NAMESPACE
>> import(methods)
>> importFrom("graphics", image)
>>
>> exportClasses(....)
>> exportMethods(image)

conceptually, having created the generic it seems like you should export it, but exportMethods will export the generic as well.

Your package actually installs under R-devel, and I wonder if this is a manifestation of the bug reported here

https://stat.ethz.ch/pipermail/r-devel/2012-April/063783.html

A work-around seems to be an unconditional setGeneric("image").

Martin

>>
>>
>> If the problem is because of the exportMethods(), I'm left
>> stumped as to how to work around this. Making our S4 objects
>> useable externally was kind of the point.
>>
>>
>> Source package available, if needed.
>>
>> oompa<- "http://bioinformatics.mdanderson.org/OOMPA/2.14"
>> download.packages("SuperCurve", destdir=".", repos=oompa, type="source")
>>
>> ______________________________________________
>> R-devel_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 13 Apr 2012 - 13:11:16 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Fri 13 Apr 2012 - 20:40:45 GMT.

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

list of date sections of archive