Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

very large flow diagrams #186

Open
chumbleycode opened this issue Oct 23, 2024 · 5 comments
Open

very large flow diagrams #186

chumbleycode opened this issue Oct 23, 2024 · 5 comments

Comments

@chumbleycode
Copy link

chumbleycode commented Oct 23, 2024

love the package! I have not had useful visualizations when applied to a very long piece of code (everything is way too small to see with the naked eye!!). Unfortunately this is where it is most useful to me. Do you have any ideas and pointers?

@moodymudskipper
Copy link
Owner

Thanks for the kind words!
I generally use out = "png", This way you can view better and zoom conveniently.
To have a more compact output you can also use code = FALSE, you'll see the control flow but not the code chunk, sometimes it helps.
Another trick can be to use out = "html" after setting options(flow.svg = TRUE). The you should be able to zoom in as much as the software you used to open html files allows you to since it'll be vectorial.
Some very big diagrams are just not rendered, and for this unfortunately I have no easy solution (the not easy solution is to manipulate the code of the function to extract some parts but it's a lot of work).

Please tell me if any of those helps!

@chumbleycode
Copy link
Author

Thanks so much for your pointers. You are a star! I have found that the code is sometimes just too long for any of these workarounds. I guess that it is hard to split such diagrams and spread them over multipel pages! I'll certainly use your package more though.

@moodymudskipper
Copy link
Owner

In fact the act of splitting the diagram itself is not so hard because the code in R can be converted to a nested list and we can just pick one part out, to print it as a second step, but the action of selecting the right part to extract is hard:

  • hard to do automatically (maybe with graph theory we can define some heuristics but I don't really know where to start)
  • hard to do it manually, how do I help you select the part you want to extract ?

For the latter, just thinking out loud, maybe we could have a special comment that would extract everything under this comment until we reach an upstream branch or another special comment.

@llrs
Copy link
Contributor

llrs commented Oct 25, 2024

I too encountered this problem when trying this on huge base R functions (>1200 LOC).

I think that the second solution could be doable. Blocks of code are in a depth level x (from top to bottom). One could split a graph every 5 levels, or specifically decide to focus on levels 4 to 5. This would require splitting the functionality of calculating the drawing and actually plotting it (and calculate the depth of each block). I think this would work well also internally (and could open the door to compare different versions of the same function when refactoring).
HTH

@chumbleycode
Copy link
Author

Here is an example that doesn't currently display very successfully flow::flow_view(multinma:::predict.stan_nma)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants