htmlrrstudior-markdowncanvas-lms

Displaying RMarkdown HTML output in the CANVAS LMS


I am trying to display R code and output in the CANVAS LMS (specifically within a page, not just as a separate html file). I have had no joy Googling this so hopefully someone can help.

What I have tried (as a simple test) but hasn't worked: In RStudio created a new RMarkdown HTML document (the basic default one with a sample table and sample plot). Used Knitr to create the html file. Opened HTML file and copied code into the LMS (raw html editor). This kind of works but doesn't show the plot and has some of the code that I didn't need to copy (see image).

Presumably there is a smarter way to do this but I can't find any good resources.

Canvas vs actual html


Solution

  • There were two issues here. I solved (1) and have identified but not fully solved (2)

    1. One was that I should have been using output: html_fragment instead of html_document to get html to embed in to Canvas (otherwise it is trying to put html inside html and gets confused)
    2. The second I haven't fully resolved but the issue is that when I hit save on the Canvas page the editor strips any base64 images (which is all the plots). I haven't worked out if this is a general issue or the particular editor that is being used on the version of Canvas I am working with.