1

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 help_console function from noamtools R package. I tried this code but not working:

help_console(topic="Yates", format = "latex")

and

help_console(topic="FrF2:Yates", format = "latex")

The noamtools Rpackage can be obtained fromgithub` using the following commands:

library(devtools)
install_github("noamtools", "noamross")
library(noamtools)
halfer
  • 19,824
  • 17
  • 99
  • 186
MYaseen208
  • 22,666
  • 37
  • 165
  • 309

1 Answers1

3

The issue here is in the function help from the base package utils. You have two packages that are both exporting a function with the same name. Specifically, DoE.base and FrF2 both export Yates, so help doesn't load an Rd file; instead, it wants you to choose between different files. But help_console doesn't know how to handle this. This can be easily corrected by adding a package argument to help_console that passes a package name down to help. To create achieve this in a particular R session, you can use:

fixInNamespace("help_console", "noamtools")

to load a script editor where you can change the definition of help_console to the following:

function (topic, format = c("text", "html", "latex", "Rd"), lines = NULL, 
    before = NULL, after = NULL, package = NULL) 
{
    format = match.arg(format)
    if (!is.character(topic)) 
        topic <- deparse(substitute(topic))
    helpfile = utils:::.getHelpFile(help(topic, package = (package)))
    hs <- capture.output(switch(format, text = tools:::Rd2txt(helpfile), 
        html = tools:::Rd2HTML(helpfile), latex = tools:::Rd2latex(helpfile), 
        Rd = tools:::prepare_Rd(helpfile)))
    if (!is.null(lines)) 
        hs <- hs[lines]
    hs <- c(before, hs, after)
    cat(hs, sep = "\n")
    invisible(hs)
}

This will then allow you to separately capture the documentation for each version of the function:

str(capture.output(help_console(topic="Yates", format = "latex", package="FrF2")))
## chr [1:139] "\\HeaderA{utilitiesCat}{ \\textasciitilde{}\\textasciitilde{} Internal utility functions and a user-visible constant for workin"| __truncated__ ...
str(capture.output(help_console(topic="Yates", format = "latex", package="DoE.base")))
## chr [1:65] "\\HeaderA{block.catlg3}{Catalogues for blocking full factorial 2-level and 3-level designs,  and lists of generating columns fo"| __truncated__ ...

In order to get this incorporated into noamtools, I've issued a pull request for this to be changed. You can see it here on GitHub. It has now been merged in the main repo on GitHub, so you can install as you normally would.

Thomas
  • 43,637
  • 12
  • 109
  • 140