This question is about using roxygen2 and not about how to override a function.
I am using roxygen2 for a CRAN package and I am trying to achieve the following:
There is a function called my.function
whose function name I want to replace with my_function
.
I want to do this gradually - so for some time both functions names shall be available.
For a first step I'd like to have the following:
If a user explicitly calls ?my.function
they shall come to the documentation of my.function
function (or to the documentation of my_function)
But if a user calls help(package="myPackage")
my.function
shall not appear in the functions list
The background is, if a user explicitly searches for the old function name, they will still find it. But if they are just generally searching for available functions (because they are new to the package) they will only get to new name.
How can I do this?
I was experimenting with combinations of the following roxygen tags:
@noRd
@alias
@describeIn
@rdname
But I was not able to achieve my desired result. I am asking specifically about the roxgen2 documentation part, not about overriding a function in R in general.
You can disable functions from being listed in the package manual by adding @keywords internal
to the roxygen comments (see e.g. the Object documentation section of R packages), but as mentioned by Hong Ooi the proper way is probably to deprecate my.function
(see the Releasing a package section of R packages).