How can I print the R documentation from a Linux shell (like bash)?
How can I check documentation for R code from a Linux shell like bash? I do NOT mean an interactive session.
With Perl, I can use perldoc
to print documentation on the command line:
perldoc lib
I was hoping for something simpler for R. I don't always want to pull up a full interactive R session to find documentation.
source to share
There may be other ways, but the flag works for me -e
to execute the code on the command line. I also use a flag --slave
that does not allow anything to be printed to standard output (e.g. no messages about starting R, etc.):
R --slave -e '?function'
Actually I created a super small script I am calling rdoc
to act like a simple R version perldoc
:
#!/bin/bash
R --slave -e "?$1"
After installing this in my directory ~/bin
(or, nevertheless, installing it in PATH
), it's easy:
rdoc function
If you want to see the documentation for a function from a specific package, add the library name followed by two colons. For example, to pull the documentation of a function dmrFinder
out of a package charm
:
rdoc charm::dmrFinder
source to share