bruigtp / flowchart

flowchart is an R package for drawing participant flow diagrams directly from a dataframe using tidyverse.
https://bruigtp.github.io/flowchart/
Other
36 stars 1 forks source link

question #3

Closed higgi13425 closed 1 month ago

higgi13425 commented 1 month ago

how can you create a line for each reason for exiting a study? i.e. 12 left due to flare of a disease 3 left due to rash 2 left due to headache

higgi13425 commented 1 month ago

is this already possible?

pasahe commented 1 month ago

Yes, this is possible using the fc_modify() function. You can see an example of how this can be done in the vignette's Example 2.

In the first piece of code is where all the text for the reason for exiting a study is created: label_exc1 and label_exc2. Then, after creating the basic flowchart we can use the fc_modify() function to replace the original text of the desired boxes for the previously created text in this specific line:

text = case_when(id == 11 ~ label_exc1, id == 13 ~ label_exc2, TRUE ~ text)

Hope this helps you.

Thanks for the post!

higgi13425 commented 1 month ago

This is really great! Thanks for creating and sharing this package!