From br@@e|m @end|ng |rom he|mho|tz-muenchen@de  Tue Nov 19 10:38:28 2019
From: br@@e|m @end|ng |rom he|mho|tz-muenchen@de (Herbert Braselmann)
Date: Tue, 19 Nov 2019 10:38:28 +0100
Subject: [Rd] S3 methods in packages. Change in R 4.0.0?
In-Reply-To: <858d3a6c-a293-ede9-7edf-cb535e524fe4@gmail.com>
References: <a756cc27-e442-8c9e-de11-01aabc8fd300@helmholtz-muenchen.de>
 <858d3a6c-a293-ede9-7edf-cb535e524fe4@gmail.com>
Message-ID: <d3726275-a032-890e-e9ed-9ab66ab883ff@helmholtz-muenchen.de>

Thank you Duncan,

I declared now my S3methods in the NAMESPACE file. This works, at least 
locally on my machine. But I assume that my package version on the devel 
branch of Bioconductor will be built in the next hours.

Herbert


Am 16.11.19 um 16:29 schrieb Duncan Murdoch:
> On 15/11/2019 8:42 a.m., Herbert Braselmann wrote:
>> Hello,
>>
>> since Bioconductor devel branch 3.11 started, which is operating with
>> R-devel 4.0.0 (for e.g. 2019-11-03 r77362 on OS X 10.11.6 El Capitan),
>> my package CFAssay 1.21.0 is not built on none of all three Systems,
>> Linux, Windos and Mac. The error message refers to xy.coords which is
>> called by R function plot.default. I found out that it has to do with
>> the S3 object system. In my package I defined an S3 method for R generic
>> plot and three for print. To be free from the biological stuff I
>> generated here a simple example package:
>>
>> https://github.com/ZytoHMGU/myfirstS3steps
>>
>> A simple method? 'print.my1stClass' is defined there, which writes the
>> sumproduct of two numerical entries or numbers of a list, given a class
>> attribut matching the name of the method. Up to R 3.6.1 it works as one
>> is used to expect from S3 methods. After attaching the package in R
>> 4.0.0, a call of 'print' for a list object of that class falls back to
>> 'print.default' and writes the list entries. However, when the method is
>> sourced, so that it appears in the global environment, it works as
>> expected for S3 with a 'print'. Independently thereof, the method is
>> shown in the list with .S3methods(print) or 
>> .S3methods(call="my1stClass").
>
> You aren't declaring your method as a method in the NAMESPACE file.? I 
> hadn't noticed a news item saying that the necessity for this had 
> changed, but it is definitely something you should do. Put this into 
> NAMESPACE:
>
> S3method(print, my1stclass)
>
> and it should be fine.
>
> Duncan Murdoch
>
>
>>
>> A similar problem has function plot, I don't show it here. It leads to
>> an error message, when plot.default and xy.coords cannot work with the
>> object for which the method was written. I guess that methods for
>> 'summary' and all other R base generics, written in a package as I did
>> it and attached with the library command would have the same problem in
>> R-devel 4.0. I did not try it. My questions are now:
>>
>> (1) Is action required or is it a bug in 4.0?
>> (2) Should I be more stringent, for e.g. using special directives in the
>> NAMESPACE file of the package? I did not.
>> (3) Should I change to S4? For e.g. Bioconductor package CGHbase (Mark
>> van de Wiel) contains S4 plot-methods for its objects.
>>
>> For whom it may be interesting the URL of my Bioconductor package:
>> http://bioconductor.org/checkResults/devel/bioc-LATEST/CFAssay/
>>
>> Herbert Braselmann
>> <http://bioconductor.org/checkResults/devel/bioc-LATEST/aCGH/>
>>
>
-- 
Abteilung Strahlenzytogenetik / Research Unit Radiation Cytogenetics
AG Integrative Biologie / Working group Integrative Biology
Tel./Phone: +49 89 3187-2878
  

 

Helmholtz Zentrum M?nchen



[Rd] S3 methods in packages. Change in R 4.0.0?
Herbert Braselmann