Skip to contents

[qd_save()] is a light wrapper around [DiagrammeR::export_graph()], which enables exporting high-quality and/or scalable graphics for both print and online. For convenience in computational notebooks like quarto or RMarkdown documents, [qd_save()] also allows the user to embed the image via [knitr::include_graphics()].

Usage

qd_save(graph, file_name, ..., embed = FALSE, kg = NULL)

Arguments

graph

A graph object produced by [qd_dag()]

file_name

A filename (possibly including a path) to which to save the image. File type will be determined by the extension provided (pdf, svg, png, ps). See [DiagrammeR::export_graph()] for details.

...

Pass other arguments to [DiagrammeR::render_graph()].

embed

Defaults to `FALSE`. Automatically set to `TRUE` by [qd_embed()].

kg

A list allowing the user to set arguments for [knitr::graphics()] (except for `path`).

Examples

if (FALSE) { # \dontrun{
dag <- qd_dag(c("L -> {A Y}", "A -> Y"))
qd_save(dag, "dag.pdf")

# embed from code chunk using knitr::include_graphics()
qd_save(dag, "dag.pdf", embed = TRUE)

# `title` passed to DiagrammeR::export_graph()
qd_save(dag, "dag.pdf", title = "Demo")
} # }