Embedding the result of R code in a function documentation

Hello everyone,

I'd like to know if there is a way to embed R code in a function documentation but I don't want the R code to appear as it is in the documentation, I'd like only to show the result of its execution.

An example would be typing in the documentation something like 2 * c(1, 2, 3) and the result of it embedded in the doc.

My usecase is more complicated than this example but the idea is the same.

Thanks

1 Like

I think you are asking about how to use R Markdown ?
https://rmarkdown.rstudio.com/

If you are talking about actual function documentation you probably want to use roxygen2 check out this chapter http://r-pkgs.had.co.nz/man.html#roxygen-comments

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

It is worth mentioning that now you can also use inline R code blocks and proper triple-backtick code fences in Roxygen documentation. See more here: https://roxygen2.r-lib.org/articles/rd-formatting.html#dynamic-r-code

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

That is exactly what I was looking for. Thanks !