as.igraph.DAG | R Documentation |
igraph
object
This function extends the as.igraph
function from the igraph
package to allow the input of a DAG
object. The result is an igraph
object that includes only the structure of the DAG, not any specifications. May be useful for plotting purposes.
## S3 method for class 'DAG'
as.igraph(x, include_root_nodes=TRUE,
include_td_nodes=TRUE, ...)
x |
A |
include_root_nodes |
Whether to include root nodes in the output matrix. Should usually be kept at |
include_td_nodes |
Whether to include time-dependent nodes added to the |
... |
Currently not used. |
Returns a igraph
object.
Robin Denz
empty_dag
, node
, node_td
library(simDAG)
# some example DAG
dag <- empty_dag() +
node("death", type="binomial", parents=c("age", "sex"), betas=c(1, 2),
intercept=-10) +
node("age", type="rnorm", mean=10, sd=2) +
node("sex", parents="", type="rbernoulli", p=0.5) +
node("smoking", parents=c("sex", "age"), type="binomial",
betas=c(0.6, 0.2), intercept=-2)
if (requireNamespace("igraph")) {
g <- igraph::as.igraph(dag)
plot(g)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.