Roxygen believes my function is an S3 method and therefore breaks when installing my package

I use roxygen to create my own package. I have a function that causes a problem:

##' extract.sig.metadata ##' @param foo bar ##' @author me ##' @export extract.sig.metadata <- function(foo){ # does stuff } 

I created a package skeleton (with create (my-package) from devtools) and I used document () to handle roxygen tags. However, when I try to install my package, it fails:

... * setting reference indices ** building package indices ** testing if the installed package can be downloaded Error: the extract object was not found during the loading of the my-package namespace Error: loading failed The execution was paused

I am sure that roxygen believes that extract.sig.metadata is an S3 method, that is, a specialized form of export (), but it does not find the export () function, and therefore it breaks. But this is not the s3 method, it is just a function called extract.sig.metadata. If I look in the Rd code, the / use tag looks weird:

 \usage{ \method{extract}{sig.metadata}(spec.df, var = "product_name", ratio.cutoff = 0.001, prob.modifer = 3, frequency.cutoff = NA, verbose = F, assign.to.global.env = FALSE, use.bigrams = T, clean = T, ngram.dupe.n.cutoff = 0.1, max.obs = 10000) } 

If I change the name to extractSigMetadata, the problem has been technically fixed and the .Rd code will change,

 \usage{ extractSigMetadata(foo) } 

But I would really like not to change the name of my function (there are dozens of functions that have the same problem in my package, and they are used in a bunch of scripts - it would be a huge pain to change the name scheme not).

---> Does anyone know how I can tell roxygen that this is a normal function and not a weird s3 method? I suppose this has something to do with the @method tag, but I don't know how to use it correctly to make this work. Thanks!!!

+6
source share
1 answer

Fixed!

Using @export extract.sig.metadata instead of @export seems to tell roxygen that extract.sig.metadata is the full name of the function, and this fixes the problem. In this particular case, I did not have a general extraction function, but R.utils (a package that my package did not depend on, but still loaded) had an extraction function.

Hope this helps anyone who has the same problem in the future. Thanks!

PS Hadley offers the best naming practices that I will try to follow in the future.

+5
source

Source: https://habr.com/ru/post/971393/


All Articles