No, sorry, it was also a problem with `Matrix` package. I was too quick in checking it. I think upgrading my devtools and roxygen2 may have fixed it. Thanks for helping me pinpoint where the problem was.
> On Oct 19, 2018, at 12:37 PM, Elizabeth Purdom <epur...@stat.berkeley.edu> > wrote: > > Thanks Martin. And of course you’re right! The errors I was getting came from > devtools functions— I didn’t think to check it outside of there and assumed > it was a general problem with my package setup. But it's actually a problem > in devtools. > > When I set up your example (thanks!) with Roxygen as follows: > > #' @import methods > #' @importMethodsFrom phylobase nNodes > .A = setClass("A", slots = c(x="numeric")) > > #' @export > setMethod("nNodes", "A", function(x) "I'm an 'A’") > > Then I get the following errors with `document` and `load_all` > >> document() > Updating PkgA documentation > Loading PkgA > Error in setMethod("nNodes", "A", function(x) "I'm an 'A'") : > no existing definition for function ‘nNodes’ > >> load_all() > Loading PkgA > Error in setMethod("nNodes", "A", function(x) "I'm an 'A'") : > no existing definition for function ‘nNodes’ > > But it does seem related to the `nonStandardGeneric`, since I don’t have this > problem when I use the Matrix package instead, which creates > `standardGeneric`: > > #' @import methods > #' @importMethodsFrom Matrix isDiagonal > .A = setClass("A", slots = c(x="numeric")) > > #' @export > setMethod("isDiagonal", "A", function(object) "I'm an 'A'") > >> document() > Updating PkgA documentation > Loading PkgA > Writing NAMESPACE > Writing NAMESPACE > > I’ll submit the problem in devtools. > > I guess for the upcoming Bioconductor release I’ll switch the package to > `Depends` to get my documentation and any final bugs, and at the last minute > I’ll put it back to `Imports`. > > Thanks, > Elizabeth > >> On Oct 19, 2018, at 12:03 PM, Martin Morgan <mtmorgan.b...@gmail.com> wrote: >> >> That doesn't sound correct. I just created a simple package with >> >> DESCRIPTION >> >> Package: PkgA >> Title: What the Package Does (one line, title case) >> Version: 0.0.0.9000 >> Authors@R: person("First", "Last", email = "first.l...@example.com", role = >> c("aut", "cre")) >> Description: What the package does (one paragraph). >> Depends: R (>= 3.5.1) >> Imports: phylobase, methods >> License: Artistic-2.0 >> Encoding: UTF-8 >> LazyData: true >> >> NAMESPACE >> >> import(methods) >> importMethodsFrom(phylobase, "nNodes") >> exportMethods("nNodes") >> >> and R/cls.R >> >> .A = setClass("A", slots = c(x="numeric")) >> setMethod("nNodes", "A", function(x) "I'm an 'A'") >> >> This package builds and checks OK (complaining about documentation, but...) >> and nNodes can be used. >> >> Do you have more information on the problem that you are seeing? Is it a >> problem with roxygen2? >> >> Martin >> >> >> On 10/19/18, 12:18 PM, "Bioc-devel on behalf of Elizabeth Purdom" >> <bioc-devel-boun...@r-project.org on behalf of epur...@stat.berkeley.edu> >> wrote: >> >> Sorry, I copied the wrong code from phylobase (I copied the setMethod >> code). Their setGeneric calls are in the following format: >> >> setGeneric("nNodes", function(x) { >> standardGeneric("nNodes") >> }) >> >> >>> On Oct 19, 2018, at 9:07 AM, Elizabeth Purdom <epur...@stat.berkeley.edu> >>> wrote: >>> >>> Hello, >>> >>> In my package (`clusterExperiment`) I want to extend a S4 method from a >>> package `phylobase` for my class. However, in the phylobase package, all of >>> the `setGeneric` calls are in the form of >>> >>> setMethod("nTips", signature(x="phylo"), >>> function(x) { >>> Ntip(x) >>> }) >>> >>> Namely, they use braces in their function definitions, which I have just >>> learned creates a `nonstandardGenericFunction` rather than a >>> `standardGeneric`. Because of this I can’t just do `importMethodFrom` and >>> then just extend the method. And if I try to create my own >>> `standardGeneric` (e.g. >>> https://stat.ethz.ch/R-manual/R-devel/library/methods/html/Methods_for_Nongenerics.html >>> >>> <https://stat.ethz.ch/R-manual/R-devel/library/methods/html/Methods_for_Nongenerics.html>) >>> I can no longer call the function in the original `phylobase` package, >>> i.e. for the original class for which it is applied. >>> >>> My only solution appears to be if I put `phylobase` in the `Depends` >>> section, at which point I can then extend their generics. But this gives my >>> package the significant warning: >>> >>> " Warning: replacing previous import ‘phylobase::plot’ by ‘graphics::plot’ >>> when loading ‘clusterExperiment’” >>> >>> My question is whether there is anything I can do on my end to either 1) >>> extend phylobase generics without a depends statement or 2) to get rid of >>> the warning about the imports (I have made sure to use `graphics::plot` in >>> all of my functions’ calls to plot to make sure there is no problem with >>> the import conflict)? >>> >>> Or is my only hope to have the developers of the package fix their calls? >>> Personally, I was going to strip my setGeneric calls of braces after this >>> experience, since I also have braces in my call but not for any good >>> reason. Is there a good reason that setGenerics might have the braces in >>> their calls? (Hadley’s Advanced R seems to say no, perhaps for this reason >>> https://adv-r.hadley.nz/s4.html#generics-and-methods >>> <https://adv-r.hadley.nz/s4.html#generics-and-methods>). Does using braces >>> keep you from colliding with future developers or other packages? >>> >>> Thanks, >>> Elizabeth >>> >>> >>> >>> >> >> >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> Bioc-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/bioc-devel >> > _______________________________________________ Bioc-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel