library(magrittr) library(knitr) code_tree <- cctu:::cctu_env$code_tree root <- code_tree[1, 1] PATH <- gsub("\\\\ROOT$", "", root, perl = TRUE) code_tree %<>% within({ parent %<>% gsub("\\\\", "/", ., fixed = TRUE) %>% gsub(PATH, "", ., fixed = TRUE) child %<>% gsub("\\\\", "/", ., fixed = TRUE) %>% gsub(PATH, "", ., fixed = TRUE) }) graphcode <- function(edges, node, rootnode = TRUE) { # edges is a data.frame with two columns: parent, child if (length(node)) { children <- subset(edges, parent == node)$child if (!rootnode) { output <- " child{ " } if (rootnode) { output <- "" } output <- c(output, "node{ ", node, "} ") # if(rootnode){ output <- c(output, "[grow=right] ")} for (child in children) { output <- c(output, Recall(edges, child, rootnode = FALSE)) } if (!rootnode) { output <- c(output, " }") } } else { output <- "" } output } graph <- graphcode(code_tree, code_tree[1, 1]) graph <- gsub("\\\\", "/", graph) graph <- gsub(PATH, "", graph) graph <- gsub("_", " ", graph) graph <- paste(c("\\", graph, ";"), collapse = "") graph # sibling distance=20em,
\begin{tikzpicture}[edge from parent fork right, level distance=20em, grow'=right,
every node/.style = {shape=rectangle, rounded corners,draw, align=center, fill=white}]
r knit_child(text=graph)
\end{tikzpicture}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.