I am creating a markdown presentation and am generating a graph with the library data.tree. When I generate the presentation I get this error
Error: Functions that produce HTML output found in document targeting beamer output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:
Note however that the HTML output will not be visible in non-HTML formats.
Parent = Node$new("Parent Node")
Child = Parent$AddChild("Child Node")
SetNodeStyle(Tree, fontsize = "24")
You may have been downvoted because this code
library(data.tree) Parent = Node$new("Parent Node") Child = Parent$AddChild("Child Node") SetNodeStyle(Tree, fontsize = "24") plot(Tree)
does not run, even outside the context of a markdown presentation. This is because "Tree" has not been defined. The tree object you're trying to refer to as "Tree" is what you've named "Parent". For a reproducible example, try:
library(data.tree) Tree = Node$new("Parent Node") Child = Tree$AddChild("Child Node") SetNodeStyle(Tree, fontsize = "24") plot(Tree)
Now how to get that plot into a slide:
You're on the right track with
saving the html and loading it in from a local directory
except you need to actually export it as something TeX can understand, not just save it as html. In RStudio, if you run the code above and produce the plot independently (not as part of the presentation), you have the option to "Export" > "Save as Image" directly from the viewer pane.
Supposing you've saved the plot in your working directory as "treeplot.png", you can then insert it into your presentation like so:
--- title: "Trees" output: beamer_presentation --- ## Slide 1 !(treeplot.png)
This technique for inserting an image from a file is covered in the RMarkdown Reference Guide