Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Created July 18, 2025 10:24
Show Gist options
  • Save abikoushi/c46f6943e8d585dfbbb66db3acfbc11e to your computer and use it in GitHub Desktop.
Save abikoushi/c46f6943e8d585dfbbb66db3acfbc11e to your computer and use it in GitHub Desktop.
因果ダイアグラム:DiagrammeR使ってみた
library(DiagrammeR)
library(DiagrammeRsvg)
library(magrittr)
library(rsvg)
##佐藤俊哉『宇宙怪人しまりす 統計よりも重要なことを学ぶ』(朝倉書店)より
g <- grViz("digraph{
graph[rankdir = TB]
node[shape = rectangle]
A[label = 'かぜの\n重症度']
B[label = 'ヨクナール\n使用']
C[label = 'かぜ症状の\n回復']
edge[color = black]
A -> B
A -> C
B -> C
}")
print(g)
g %>% export_svg() %>%
charToRaw() %>%
rsvg_png("graph.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment