保存成图片的方式
对于 github_document等方式,需要静态图片,这里 参考cran
提供解决方案
生成时间有点长。
## Error in `knitr::include_graphics()`:
## ! Cannot find the file(s): "FakeDataFig.png"
vtreeuses theDiagrammeRpackage (which in turn is built on the open source graph visualization software,Graphviz).
grVizToPNGThe name of the graphics file (example1.png) is automatically derived from the name of the object (
example1).
实现方式 js→svg→png
这是解决方式
function (g, width = 3000, folder = ".")
{
argname <- sapply(as.list(substitute({
g
})[-1]), deparse)
message <- utils::capture.output(svg <- DiagrammeRsvg::export_svg(g))
result <- rsvg::rsvg_png(charToRaw(svg), paste0(folder,
"/", argname, ".png"), width = width)
invisible(NULL)
}## <srcref: file "" chars 1:1 to 10:1>
双向箭头
a -> b [dir=both] 参考Github
Issue 252