Version 0.1.0 features experimental functions to display different kinds of flow diagrams.
These are not stable but already useful and since developing flow takes time I though it’d be useful to release them as they are for the time being. Please report issues or upvote existing ones on github if you’d like to see more work happening there.
flow_view_vars()
flow_view_vars()
shows dependencies between variables in a function, this kind of functions cannot be made completely robust but seems to work quite well if you don’t use assign
and don’t reuse variable names all over the place.
Full lines are direct dependencies, dashed lines are dependencies through control flow. Variables are repeated when they are modified.
Let’s test it on tidyselect::ends_with
::ends_with
tidyselect#> function (match, ignore.case = TRUE, vars = NULL)
#> {
#> check_match(match)
#> vars <- vars %||% peek_vars(fn = "ends_with")
#> if (ignore.case) {
#> vars <- tolower(vars)
#> match <- tolower(match)
#> }
#> length <- nchar(vars)
#> flat_map_int(match, ends_with_impl, vars, length)
#> }
#> <bytecode: 0x1086fb6e0>
#> <environment: namespace:tidyselect>
flow_view_vars(tidyselect::ends_with)
If we don’t want to repeat the variable we can set expand = FALSE
, the resulting diagram doesn’t reflect the sequence of modifications but sums up dependencies more clearly as it is more compact.
flow_view_vars(tidyselect::ends_with, expand = FALSE)
Use the out
argument to export these diagrams.
flow_view_deps()
flow_view_deps()
shows dependencies between functions in a package.
Exported functions are blue, unexported are yellow, the number of lines of code is indicated between brackets (useful to detect small helpers).
By default functions called from other non base packages are shown but don’t create new nodes.
flow_view_deps(tidyselect::ends_with)
We can collapse those to show only packages :
flow_view_deps(tidyselect::ends_with, show_imports = "packages")
Or not show those at all :
flow_view_deps(tidyselect::ends_with, show_imports = "none")
There are many ways to tweak the output, in particular we can :
flow_view_deps(tidyselect::ends_with, promote = "purrr::map")
flow_view_deps(tidyselect::ends_with, demote = "peek_vars")
flow_view_deps(tidyselect::ends_with, hide = c("peek_vars", "purrr::map"))
flow_view_deps(tidyselect::ends_with, trim = "peek_vars")
Use the out
argument to export these diagrams.
flow_view_shiny()
flow_view_shiny()
is a wrapper around flow_view_deps()
to show the structure of a shiny app. It works nicely on apps built with {golem} or follow the same kind of structure (good practice basically). Apps that use source()
are not well supported but it might come as we found it’s quite common (though probably not good practice).
Here’s an example using the great {esquisser} app.
flow_view_shiny(esquisse::esquisser, show_imports = "none")
Use the out
argument to export these diagrams.