Get loaded package's function X title programmatically

时间:2015-09-14 15:41:13

标签: 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?

1 个答案:

答案 0 :(得分:4)

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.