[R-pkg-devel] Advice on elegant way to alias function name

Neal Fultz n|u|tz @end|ng |rom gm@||@com
Thu Sep 1 16:53:40 CEST 2022


Many of Hadley Wickhams packages have things with both US and UK spellings
(summarise/summarize, color/colour), I would check ggplot2 or dplyr.

https://github.com/cran/dplyr/blob/master/R/summarise.R#L122-L124

On Thu, Sep 1, 2022 at 7:48 AM J C Nash <profjcnash using gmail.com> wrote:

> Hi,
>
> I've a package where it has been suggested that one of the functions --
> call
> it "myfn()" -- should be called something else, say "thefn()". Of course,
> I'll
> need to keep the old name around for a while.
>
> Web search has suggested simple assignment of
>
>      thefn <- myfn
>
> but I cannot seem to get this to work with R CMD check when I put this in
> a .R
> file in the code and put alias and usage stanzas in documentation. I get
> alias
> and missing argument type errors. I've tried a number of variations on
> this theme
> without appreciable success.
>
> A workaround is to copy the entire function with Roxygen2 documentation and
> name change, but this seems inelegant.
>
> Is there a better way e.g., using something like onLoad ? Pointers to
> working
> examples in CRAN or Github packages would be welcome.
>
> Best, JN
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list