ggdag | R package for working with causal directed acyclic graphs | Data Visualization library
kandi X-RAY | ggdag Summary
kandi X-RAY | ggdag Summary
Tidy, analyze, and plot causal directed acyclic graphs (DAGs). ggdag uses the powerful dagitty package to create and analyze structural causal models and plot them using ggplot2 and ggraph in a consistent and easy manner.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ggdag
ggdag Key Features
ggdag Examples and Code Snippets
Community Discussions
Trending Discussions on ggdag
QUESTION
ANSWER
Answered 2022-Mar-11 at 16:38This is a little tricky since there doesn't seem to be the option directly within the function to label colours how you would like. Perhaps the easiest way would be to add an aesthetic mapping to the point layer:
QUESTION
library(dagitty)
library(ggplot2)
library(ggdag)
get_jpg <- function(filename) {
grid::rasterGrob(jpeg::readJPEG(filename), interpolate = TRUE)
}
logo <- get_jpg("logo.jpg")
ex.1 <- dagitty("dag {
X <- A -> B <- C -> Y
X <- B -> Y
X -> W -> Y
S-> T -> C
}")
exposures(ex.1) <- 'X'
outcomes(ex.1) <- 'Y'
tidy.1 <- ex.1 %>%
tidy_dagitty() %>%
mutate(label = str_to_upper(name))
ggdag(tidy.1 , text = FALSE, use_labels = "label") + theme_dag() +
theme_light() +
annotation_custom(logo, xmin = 6.5, xmax = 8.5, ymin = -5, ymax = -8.5) +
coord_cartesian(clip = "off") +
theme(plot.margin = unit(c(1, 1, 3, 1), "lines"))
...ANSWER
Answered 2021-Oct-24 at 18:12One option to achieve your desired result would be to position the logo by setting the coordinates via rasterGrob
instead of via annotation_cutom
. Making use of the example code in the post you linked in my code below I put the R logo on the bottom right. As you can see from the two examples I added this works fine independently of the range of the data and will put the logo always on the same position:
QUESTION
I am using dagitty online browser to draw DAGs for a project: http://www.dagitty.net/dags.html#
I cannot figure out how to customise the appearance of my DAGs to make them look nice, for inclusion in a paper. Code and images are provided at the end of the post.
I would like to be able to do any of the below: A) Use superscripts instead of underscores B) Change the size of the font C) In the 'classic' style, the variable names cover the arrows in the arrow is going directly up, so you cannot see the direction of causality D) Just have variable names representing each node, instead of boxes
In the paper explaining how to use the R package of this tool, there are many DAGs which have the above mentioned properties, but the focus of the paper is to explain how to use DAGs to properly assess causality etc, nothing about the appearance of the DAGs. I would be very grateful for some help on this, or for suggestions of other tools/packages that allow you to draw DAGs. I also fear this may be better placed on the maths/statistics stack, which will likely have more users of the dagitty tool. Mods please move there if appropiate. I posted here as it's purely a coding issue.
The following code can be input in the 'model code' section of the dagitty website to reproduce the two DAG images I have provided. By choosing 'classic' or 'SEM-like' under the Diagram style, you can get the two appearances.
...ANSWER
Answered 2020-Apr-16 at 06:56Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ggdag
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page