我是R的新手,并尝试从研究中复制工作。 我希望复制此流程图:

问题描述 投票:0回答:1

这是我到目前为止的代码:

library(DiagrammeR) grViz(" digraph sample_selection { graph [layout = dot, rankdir = TB, splines = ortho, overlap = true] node [shape = box, style = filled, fillcolor = white] # Nodes for each year '2010 Survey\\nParticipants\\n(n = 32,846)' [group = years] '2011 Survey\\nParticipants\\n(n = 35,313)' [group = years] '2012 Survey\\nParticipants\\n(n = 38,974)' [group = years] '2013 Survey\\nParticipants\\n(n = 36,940)' [group = years] # Combined node '2010-2013\\n(n = 144,073)' # Exclusion nodes 'Excluded participants\\n<18 years at time of\\nsurvey\\n(n = 41,277)' 'Excluded participants\\nwithout medical visit\\nin the last 12 months\\n(45,843)' [style = 'filled,rounded', penwidth = 2, fillcolor = white, color = black] 'Excluded participants\\nwithout a usual\\nsource of care\\n(n = 8,984)' # Final sample node 'Final Sample\\npopulation (n = 47,969)\\nrepresenting 130\\nmillion individuals' # Intermediate node 'n = 102,796' 'n = 56,953' # Edges {rank = same; '2010 Survey\\nParticipants\\n(n = 32,846)'; '2011 Survey\\nParticipants\\n(n = 35,313)'; '2012 Survey\\nParticipants\\n(n = 38,974)'; '2013 Survey\\nParticipants\\n(n = 36,940)'} {rank = same; '2010-2013\\n(n = 144,073)'} '2010 Survey\\nParticipants\\n(n = 32,846)' -> '2010-2013\\n(n = 144,073)' '2011 Survey\\nParticipants\\n(n = 35,313)' -> '2010-2013\\n(n = 144,073)' '2012 Survey\\nParticipants\\n(n = 38,974)' -> '2010-2013\\n(n = 144,073)' '2013 Survey\\nParticipants\\n(n = 36,940)' -> '2010-2013\\n(n = 144,073)' '2010-2013\\n(n = 144,073)' -> 'Excluded participants\\n<18 years at time of\\nsurvey\\n(n = 41,277)' '2010-2013\\n(n = 144,073)' -> 'n = 102,796' 'n = 102,796' -> 'Excluded participants\\nwithout medical visit\\nin the last 12 months\\n(45,843)' 'n = 102,796' -> 'n = 56,953' 'n = 56,953' -> 'Excluded participants\\nwithout a usual\\nsource of care\\n(n = 8,984)' 'n = 56,953' -> 'Final Sample\\npopulation (n = 47,969)\\nrepresenting 130\\nmillion individuals' } ")

产生以下方式: enter image description here

指导如何使这些线路合并在一起?

	

没有图表解决方案,但是流程图包装件做得很好。 library(flowchart) fc1 <- as_fc(N=144073, label="2010-2013 Surveys", text_pattern = "{label}") |> fc_split(N=c(32846, 35313, 38974, 36940), label=c("2010 Survey", "2011 Survey", "2012 Survey", "2013 Survey"), text_pattern = "{label}\n(n={n})") enter image description here

fc2 <- as_fc(N=144073, label="", text_pattern = "(n={n})") |> fc_filter(N=102796, text_pattern = "(n={n})", show_exc = TRUE, label_exc = "Excluded participants\n <18 years at time\nof survey", text_pattern_exc = "{label}\n(n={n})", text_fs_exc = 8, offset_exc=0.2) |> fc_filter(N=56953, text_pattern = "(n={n})", show_exc = TRUE, label_exc = "Excluded participants\n without medical visit\n in the last 12 months", text_pattern_exc = "{label}\n(n={n})", text_fs_exc = 8, offset_exc=0.2) |> fc_filter(N=47969, label = "Final sample\n population representing\n 130 million individuals", text_pattern = "{label} (n={n})", show_exc = TRUE, label_exc = "Excluded participants\n without a usual\n source of care", text_pattern_exc = "{label}\n(n={n})", text_fs_exc = 8, offset_exc=0.2)

r diagrammer
1个回答
0
投票


    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.