4

knitr provides a neat function to compile R HTML help documents which contain evaluated examples embedded in the document. This is achieved with the knit_rd function, which has some simple input arguments

packageVersion('knitr')
[1] ‘1.12.3’

args(knit_rd)
function (pkg, links = tools::findHTMLlinks(), frame = TRUE)  

However, when the examples contain rgl code for interactive graphics these do not get embedded in the document (but I'd sure like them to be!). But I know it is possible to embed rgl into knitr documents, but I don't see an easy way to do this with knit_rd(). Is there a simple way to accomplish this?

Edit:

Here's a situation that I'm working on (BASH commands):

mkdir matlib-dir
cd matlib-dir
git clone https://github.com/philchalmers/matlib.git
Rscript -e "library('knitr');knit_rd('matlib')"

Of the various files generated documents like the vectors3d.html contain rgl code, but nothing really there because they have not been embedded.

philchalmers
  • 727
  • 7
  • 19
  • I have gotten it embedded in html documents. Not sure if it works for anything else. – Mike Wise Mar 16 '16 at 18:16
  • See the answer to this: http://stackoverflow.com/questions/14879210/including-a-interactive-3d-figure-with-knitr – Mike Wise Mar 16 '16 at 18:22
  • Can you post an example maybe? – Mike Wise Mar 16 '16 at 18:50
  • @MikeWise updated, and yes I was aware of that like but don't see how it can be incorporated directly – philchalmers Mar 16 '16 at 22:03
  • What do you mean by that? It is embedded in my html document and I can mail it around and people can see it and play with the 3d perspective. That is what I call "embedded". – Mike Wise Mar 16 '16 at 22:05
  • All that shows up is the `rgl` code in the generated HTML document, not the actual output generated from it. On the other hand, if something like `plot(1)` is called then that is included in the output. It's just `rgl` output that is not. – philchalmers Mar 16 '16 at 22:07
  • I have no problem getting `rgl` to be embedded into general documents, what I'm asking is whether this can be done for the R help files generated by `knit_rd()` – philchalmers Mar 16 '16 at 22:09
  • I see. I missed the word "help". You should put it in the title. – Mike Wise Mar 16 '16 at 22:11
  • 1
    Edited. Though it was in the first line of the description ;-P – philchalmers Mar 16 '16 at 22:13

1 Answers1

0

I think this isn't currently possible --- it would need modifications to knit_rd to call rglwidget() after each rgl call, or modifications to rglwidget to make that automatic. I'm working on the latter possibility, but it won't appear soon.

user2554330
  • 37,248
  • 4
  • 43
  • 90