Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

dagR2dagitty

Create dagitty code from a dagR DAG


Description

Translates a DAG as defined in a dagRdag object created by dagR into the dagitty package format. Node labeling follows the rules used for plotting dagRdag objects, but adjusted nodes are marked by a preceding underscore instead of under- and over-line.

Usage

dagR2dagitty(x, alt.symb = TRUE, only.code = TRUE)

Arguments

x

The dagR DAG to be translated.

alt.symb

Boolean indicating if the alternative node symbols should be used.

only.code

If TRUE, a string with R dagitty function call is returned, which should be checked by the user (and possibly edited as required) before running it to create an equivalent dagitty DAG. If FALSE and the dagitty package has been installed and loaded, the dagitty function is called directly and the resulting dagitty DAG is returned.

Value

Either a string containing dagitty syntax to translate the dagR DAG into dagitty format, or a dagitty object.

Author(s)

Lutz P Breitling <l.breitling@posteo.de>

References

https://cran.r-project.org/web/packages/dagitty/index.html

See Also

Examples

ex2<-dag.adjust(demo.dag4(),3);
plot(ex2);
dd2<-dagR2dagitty(ex2);
class(dd2);
dd2;

## Not run: 
dd2<-dagR2dagitty(ex2, only.code=FALSE);
class(dd2);
plot(dd2);

## End(Not run)

dagR

R Functions for Directed Acyclic Graphs

v1.2.0
GPL-2
Authors
Lutz P Breitling
Initial release
2021-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.