I would like to get the title of a base function (e.g.: rnorm) in one of my scripts. That is included in the documentation, but I have no idea how to “grab” it.
I mean the line given in the RD files as \title{} or the top line in documentation.
Is there any simple way to do this without calling Rd_db function from tools and parse all RD files — as having a very big overhead for this simple stuff? Other thing: I tried with parse_Rd too, but:
- I do not know which Rd file holds my function,
- I have no Rd files on my system (just rdb, rdx and rds).
So a function to parse the (offline) documentation would be the best 🙂
POC demo:
> get.title("rnorm")
[1] "The Normal Distribution"
If you look at the code for
help,you see that the functionindex.searchseems to be what is pulling in the location of the help files, and that the default for the associated find.packages() function is NULL. Turns out tha tthere is neither a help fo that function nor is exposed, so I tested the usual suspects for which package it was in (base, tools, utils), and ended up with “utils:So:
What you are asking for is
\title{Title}, but here I have shown you how to find the specific Rd file to parse and is sounds as though you already know how to do that.EDIT: @Hadley has provided a method for getting all of the help text, once you know the package name, so applying that to the index.search() value above: