MYaseen208
MYaseen208

Reputation: 23898

Getting help of R function using helpExtract function

I can get help in R 3.1.2 on Yates function from FrF2 package through:

?FrF2::Yates

Now I want to get help in .tex format through helpExtract function unction which can be obtained from here (written by @AnandaMahto). I tried this code but not working:

helpExtract(FrF2:Yates, section = "Examples", type = "s_text")

I wonder if there is any way to mention the package name in helpExtract function?

Upvotes: 0

Views: 60

Answers (1)

IRTFM
IRTFM

Reputation: 263311

This will take a function name and return a package name:

 pkg <- function(fn) find( deparse(substitute(fn) )  )
 pkg(mean)
#[1] "package:base"

But I think it's going to have trouble with the ?pkg::func format so I pulled out everything before the last ":" with gsub:

pkg <- function(fn) find(gsub(".+[:]","", deparse(substitute(fn) ) ) )
pkg(base::mean)
[1] "package:base"

Upvotes: 1

Related Questions