R functions' aliases documentation

1.9k views Asked by At

I'm working on R package. I set aliases for some functions this way:

foo <- function(){
    do_something
}

foo_alias <- foo

I have the documentation for 'foo' function, so when typing:

?foo

I get the created documentation. Unfortunately it does not work for foo_alias. When I type:

?foo_alias

I get nothing. Is there any solution for that so the alias function inherits the documentation from foo?

2

There are 2 answers

2
shadow On BEST ANSWER

You should add an alias to your documentation file:

\name{foo}
\alias{foo}
\alias{foo_alias}

Or if you use roxygen2:

#' @name foo 
foo <- function()

#' @rdname foo
foo_alias <- foo
0
Ambu Vijayan On

For Roxygen2:

#' @rdname foo
#' @export
foo_alias <- foo