Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get loaded package's function X title programmatically

Tags:

r

How can I get the title of a function from a loaded package programmatically? For example ?mean tells me Arithmetic Mean and ?sd's title is Standard Deviation. How could I use R to return "Arithmetic Mean" given the function name mean?

like image 377
Tyler Rinker Avatar asked Sep 27 '22 18:09

Tyler Rinker


1 Answers

You can do it using the following:

You will need the Rd_db function from the tools package to find the rd file of one of the functions (the mean in this case):

library(tools)
db <- Rd_db("base")

Then save in a variable the .Rd file of interest

therd <- db[grep("mean.Rd", names(db), value = TRUE)]

Finally just print the Title

> c(therd$mean.Rd[[1]][[1]])
[1] "Arithmetic Mean"

In the same way you can actually print other parts of the .Rd file like the description, value etc.

like image 58
LyzandeR Avatar answered Oct 18 '22 18:10

LyzandeR