[Rd] Problems with package containing S4 classes

cstrato cstrato at aon.at
Sat Mar 17 00:01:23 CET 2007


I agree, but I hope that "AllGeneric.R" is not the only possibility.
BTW, what is a collate field?

Best regards
Christian

Benilton Carvalho wrote:
> Well, my understanding is that if you "need" to define it (the 
> generic) twice you're doing something wrong.
>
> Do you have a collate field in your description file? IMHO, the 
> "AllGeneric.R"/"AllClasses.R" approach is the way to go... keeping 
> your code organized is always a good thing, right?
>
> b
>
> On Mar 16, 2007, at 6:35 PM, cstrato wrote:
>
>> Dear Benilton
>>
>> Yes, but the error disappears only when I define it twice.
>>
>> For my package I create three files:
>>
>> 1. MyClasses.R:
>> Here I define the classes only using
>> setClass("baseClass")
>> setClass("derivedClass")
>>
>> 2. methods.baseClass.R
>> Here I define the methods for baseClass
>> setGeneric("export", function(object,...) standardGeneric("export"))
>> setMethod("export", "baseClass", export.baseClass);
>>
>> 3. methods.derivedClass.R
>> Here I define the methods for derivedClass
>> setGeneric("export", function(object,...) standardGeneric("export"))
>> setMethod("export", "derivedClass", export.derivedClass);
>>
>> As you see, I need to define setGeneric twice, otherwise I get the 
>> error.
>> It is not clear to me, why this is the case?
>>
>> I know, that BioBase has a file AllGeneric.R, but I would like to define
>> the generics in the respective methods files.
>>
>> Best regards
>> Christian
>>
>> Benilton Carvalho wrote:
>>> do you have a generic for 'export'?
>>>
>>> On Mar 16, 2007, at 5:38 PM, cstrato wrote:
>>>
>>>> Dear Benilton
>>>>
>>>> Thank you, now my package works.
>>>>
>>>> Do you have an explanation for my second problem:
>>>>
>>>> * Installing *source* package 'mytest' ...
>>>> ** R
>>>> ** save image
>>>> Error in setMethod("export", "derivedClass", export.derivedClass) :
>>>>        no existing definition for function "export"
>>>> Error: unable to load R code in package 'mytest'
>>>> Execution halted
>>>>
>>>> What may be the reason for this error?
>>>>
>>>> Best regards
>>>> Christian
>>>>
>>>>
>
>



More information about the R-devel mailing list