I am trying to pretty print the help output available for some R packages, particularly when they have comments with roxygen markup.
I have tried using the R package printr, but I'm unable to get it to reproduce the nice output it shows. Instead, when I render the Rmarkdown file to PDF, it generates the source code verbatim prefixed by "##" comment markers.
"That is a natural idea. I actually tried it in the very beginning but it was tricky. The main problem is how to properly insert the LaTeX "packages" like Rd.sty into the final .tex output document, since the LaTeX output of a help page requires extra LaTeX packages."
This was back in 2018, so apparently it was very tricky. Are there any other packages that might help with this?
Knitting this MWE produces the following output. (Note that I removed most of the output it produces for brevity.)
library(printr)
library(stats)
?confint
confint
R Documentation
Confidence Intervals for Model Parameters
Description
Computes confidence intervals for one or more parameters in a fitted
model. There is a default and a method for objects inheriting from class
“lm”.
Usage
confint(object, parm, level = 0.95, ...)
Arguments
object
a fitted model object.
parm
a specification of which parameters are to be given confidence
intervals, either a vector of numbers or a vector of names. If missing,
all parameters are considered.
level
the confidence level required.
…
additional argument(s) for methods.
Details
confint is a generic function. The default method assumes
normality, and needs suitable coef and vcov
methods to be available. The default method can be called directly for
comparison with other methods.
This would be a feature request for printr package. Currently I think only the output is processed this way for HTML outputs, there is no specific transformation of the Rd help page parsing to produce valid LaTeX.
There is already a similar discussion there you could add too: