是否可以让 RStudio 显示自定义函数的函数参数和描述? [英] Is it possible to get RStudio to show function arguments and descriptions for custom functions?

查看:28
本文介绍了是否可以让 RStudio 显示自定义函数的函数参数和描述?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RStudio 中的代码完成很棒,我真的很喜欢弹出窗口描述函数输入参数的方式.例如,如果输入 matrix(,然后按tab",则会出现 matrix() 函数的参数列表以及输入的描述.说, nrow= 被选中,然后相邻窗口将 nrow 输入描述为所需的行数.".

The code completion in RStudio is great, and I really like how a popover appears to describe the arguments for the function inputs. For example, if one types matrix( and then presses "tab", a list of arguments for the matrix() function appears, along with a description of the input. Say, nrow= is selected, then the adjoining window describes the nrow input as "the desired number of rows.".

我可以让 RStudio 为我的自定义函数执行此操作吗?我是否必须创建一个包才能达到这种效果?

Can I get RStudio to do this for my custom functions? Would I have to create a package to achieve this effect?

假设我有一个充满自定义函数的文件 myCustomFunctions.R,并且我将所有杂项辅助函数存储在其中.我希望能够为我的函数添加元数据,以便此帮助窗口也描述我的函数输入.

Say I have a file full of custom functions, myCustomFunctions.R, and I store all my miscellaneous helper functions in there. I want to be able to add meta data for my functions so that this helper window also describes my function inputs.

推荐答案

为了在评论中添加 Hadley 的答案,Rstudio 正在挖掘帮助文件的特定部分以生成帮助程序窗口.具体来说,在括号之前使用 Tab 会显示用法"和描述"部分,在括号内或逗号之后使用 Tab 会显示参数"部分.因此,不仅需要制作软件包,还必须生成帮助文件才能利用此功能.

To add to Hadley's answer in the comments, Rstudio is mining specific portions of the help files to generate the helper window. Specifically, tabbing before the parentheses brings up the "Usage" and "Description" sections and tabbing inside the parentheses or after a comma brings up the "Arguments" section. Therefore, not only does a package need to be made, but the help files must be generated to take advantage of this feature.

这篇关于是否可以让 RStudio 显示自定义函数的函数参数和描述?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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