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.
There were two issues here. I solved (1) and have identified but not fully solved (2)
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)