79506476

Date: 2025-03-13 12:41:33
Score: 1
Natty:
Report link

Here is a slightly better solution than @SteffenMoritz that avoid the creation of files by using a text connection that writes into a variable string s:

display_help <- function(subject, pkg = NULL) {
    tc <- textConnection("s", "w", local = TRUE)
    tools:::Rd2HTML(utils:::.getHelpFile(help(subject, (pkg))), out = tc)
    knitr::asis_output(htmltools::htmlPreserve(s))
}

You may then use this function in code cells:

```{r, echo = F}
display_help("gold")

The `pkg` parameter may be necessary for help to find the function, just pass the package name as  a string:

display_help("geom_bar", pkg = "ggplot2")

Here is a version of the same \`display_help()\` function for Jupyter book:

display_help <- function(subject, pkg = NULL) { tc <- textConnection("s", "w", local = TRUE) tools:::Rd2HTML(utils:::.getHelpFile(help(subject, (pkg))), out = tc) IRdisplay::display_html(htmltools::htmlPreserve(s)) }

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @SteffenMoritz
  • Low reputation (1):
Posted by: pkrog