R函数的别名文档 [英] R functions' aliases documentation

查看:65
本文介绍了R函数的别名文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究R包。
我以这种方式为某些函数设置别名:

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

foo <- function(){
    do_something
}

foo_alias <- foo

foo函数的文档,因此在键入时:

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

?foo

我得到了创建的文档。不幸的是,它不适用于foo_alias。当我键入以下内容时:

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

?foo_alias

我什么也没得到。有什么解决方案,所以别名函数会从foo继承文档?

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

推荐答案

您应在文档文件中添加一个别名:

You should add an alias to your documentation file:

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

或者,如果您使用 roxygen2

#' @name foo 
foo <- function()

#' @rdname foo
foo_alias <- foo

这篇关于R函数的别名文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆