Dear List, I have a problem related to R package creation. I extended the 'show' method to cover a new class with the following lines in the zzz.R file in the R directory while creating an R package.>setClass("rpa", contains="list") >show.rpa <- function (...) {cat("rpa object \n")}The corresponding lines were also added to NAMESPACE file:>importMethodsFrom(methods,show) >exportClasses(rpa) >S3method(show,rpa)The CMD check and CMD build do not produce warning messages related to this issue (only warnings are about missing .Rd files). After installing the package ('test' is the package name) I start R and require the new package:> require(test)Loading required package: test Warning message: found an S4 version of 'show' so it has not been imported correctly So it seems that the show method is S4 version although in the package definition it is an S3 version. I would prefer not defining an S4 version for show at this point, the main goal at the moment is simply to get the package working and S3 seems to provide a quick-and-dirty way for this. Any solutions / workarounds would be appreciated. thanks in advance Leo [[alternative HTML version deleted]]
Duncan Murdoch
2009-Jul-21 00:58 UTC
[R] R package creation: 'show' extension not imported correctly
On 20/07/2009 7:53 PM, L L wrote:> Dear List, > > I have a problem related to R package creation. > > I extended the 'show' method to cover a new class > with the following lines in the zzz.R file in the R directory while creating > an R package. > >> setClass("rpa", contains="list") >> show.rpa <- function (...) {cat("rpa object \n")} > > The corresponding lines were also added to NAMESPACE file: > >> importMethodsFrom(methods,show) >> exportClasses(rpa) >> S3method(show,rpa) > > The CMD check and CMD build do not produce warning messages related to this > issue (only warnings are about missing .Rd files). > > After installing the package ('test' is the package name) I start R and > require the new package: > >> require(test) > Loading required package: test > Warning message: > found an S4 version of 'show' so it has not been imported correctly > > > So it seems that the show method is S4 version although in the package > definition it is an S3 version. I would prefer not defining an S4 version > for show at this point, the main goal at the moment is simply to get the > package working and S3 seems to provide a quick-and-dirty way for this. > > Any solutions / workarounds would be appreciated.If you only want to use S3, then don't use setClass (or anything else in the methods package). If you're using setClass, use setMethod to define an S4 method. I don't know if methods makes an attempt to support mixed styles as you used, but it really looks like a bad idea. Duncan Murdoch> > thanks in advance > Leo > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.