How can I check documentation for R code from a Linux command shell such as bash? I DO NOT mean an interactive session.
如何检查来自Linux命令shell(如bash)的R代码文档?我指的不是交互式会话。
With Perl, I can use perldoc
to print out documentation at the command line:
使用Perl,我可以使用perldoc在命令行打印文档:
perldoc lib
I was hoping for something simple like that for R. I don't always want to pull up a full interactive R session just to look up some documentation.
我希望在R中使用这样简单的东西,我并不总是想要打开一个完整的交互式R会话来查找一些文档。
1 个解决方案
#1
4
There might be other ways, but one that works for me is using the -e
flag to execute code on the command line. I also use the --slave
flag, which prevents anything from being printed to standard output (e.g. no R startup messages, etc.):
可能还有其他的方法,但是对我来说最有效的方法是使用-e标志在命令行上执行代码。我还使用-slave标志,它阻止任何东西被打印到标准输出(例如没有R启动消息等):
R --slave -e '?function'
I actually created a super small script I call rdoc
to act like a simple R version of perldoc
:
实际上我创建了一个超级小的脚本,我把它叫做rdoc,就像一个简单的R版本的perldoc:
#!/bin/bashR --slave -e "?$1"
After installing that in my ~/bin
directory (or however you install it in your PATH
), it's easy:
在我的~/bin目录中安装之后(或者在您的路径中安装它),很容易:
rdoc function
If you want to look at documentation of a function from a particular package, prepend the library name followed by two colons. For example, to pull up documentation of the dmrFinder
function from the charm
package:
如果您想从一个特定的包中查看函数的文档,请先在库名称后面加上两个冒号。例如,从魅力包中提取dmrFinder函数的文档:
rdoc charm::dmrFinder
#1
4
There might be other ways, but one that works for me is using the -e
flag to execute code on the command line. I also use the --slave
flag, which prevents anything from being printed to standard output (e.g. no R startup messages, etc.):
可能还有其他的方法,但是对我来说最有效的方法是使用-e标志在命令行上执行代码。我还使用-slave标志,它阻止任何东西被打印到标准输出(例如没有R启动消息等):
R --slave -e '?function'
I actually created a super small script I call rdoc
to act like a simple R version of perldoc
:
实际上我创建了一个超级小的脚本,我把它叫做rdoc,就像一个简单的R版本的perldoc:
#!/bin/bashR --slave -e "?$1"
After installing that in my ~/bin
directory (or however you install it in your PATH
), it's easy:
在我的~/bin目录中安装之后(或者在您的路径中安装它),很容易:
rdoc function
If you want to look at documentation of a function from a particular package, prepend the library name followed by two colons. For example, to pull up documentation of the dmrFinder
function from the charm
package:
如果您想从一个特定的包中查看函数的文档,请先在库名称后面加上两个冒号。例如,从魅力包中提取dmrFinder函数的文档:
rdoc charm::dmrFinder