[R-pkg-devel] Problems with :::
I am trying to incorporate a print method for flat tables into the package xtable which I maintain. To format the flat table before printing, I wish to use format.ftable from the base package stats. This is unfortunately not exported, so R CMD check --as-cran produces a warning because I access that function using stats:::format.ftable. So, having read the thread about this problem, I think I should copy the function into my package. I do that, and declare format.ftable as an S3 format method. Now I get a different warning: Registered S3 method from a standard package overwritten by 'xtable': methodfrom format.ftable stats I am at a loss. Any suggestions? David Scott -- _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Problems with :::
Ho David, just rename the copied function to sg else. It does not even has to be s3, probably. Gabor On 28 Jan 2016 13:16, "David Scott" wrote: > I am trying to incorporate a print method for flat tables into the package > xtable which I maintain. > > To format the flat table before printing, I wish to use format.ftable from > the base package stats. > This is unfortunately not exported, so R CMD check --as-cran produces a > warning because I access that function using stats:::format.ftable. > > So, having read the thread about this problem, I think I should copy the > function into my package. I do that, and declare format.ftable as an S3 > format method. Now I get a different warning: > > Registered S3 method from a standard package overwritten by 'xtable': > methodfrom > format.ftable stats > > I am at a loss. Any suggestions? > > David Scott > > -- > _ > David Scott Department of Statistics > The University of Auckland, PB 92019 > Auckland 1142,NEW ZEALAND > Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 > Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 > > __ > R-package-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-package-devel > [[alternative HTML version deleted]] __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Problems with :::
On 28/01/2016 7:47 AM, David Scott wrote: I am trying to incorporate a print method for flat tables into the package xtable which I maintain. To format the flat table before printing, I wish to use format.ftable from the base package stats. This is unfortunately not exported, so R CMD check --as-cran produces a warning because I access that function using stats:::format.ftable. So, having read the thread about this problem, I think I should copy the function into my package. I do that, and declare format.ftable as an S3 format method. Now I get a different warning: Registered S3 method from a standard package overwritten by 'xtable': methodfrom format.ftable stats I am at a loss. Any suggestions? stats::format() is exported, and it will delegate to format.ftable if the class of the object is "ftable". So the normal solution is just to call stats::format() on your object. If your object has a different class (e.g. "mytable"), it might be that you need to do this from your own format.mytable method. Then NextMethod() is supposed to work, assuming the class is really c("mytable", "ftable"). If the class is just "mytable", then you'll have to change it to "ftable" before calling stats::format(). Duncan Murdoch __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Problems with :::
On 28.01.2016 14:20, Duncan Murdoch wrote: If the class is just "mytable", then you'll have to change it to "ftable" before calling stats::format(). Side note: The following will fail, because format.ftable double-checks the class of its argument: format_ftable <- utils::getS3method("format", "ftable") format_ftable(mytable) -Kirill __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel