knitrflow: knitrflow: A package for knitr dataflow graphs

Description Details Examples

Description

Tools for analyzing the dataflow graph of a knitr input document based on code chunk dependencies. The package includes functions for extracting dependencies and other chunk profiling information, which can be visualized and further analyzed.

Details

The main function is knit_flow. It knits a document and extracts the necessary data for the flow graph.

The function dataflow_graph can be used inside the last knitr chunk to save the graph instead.

When using knit_flow, the option .__grab = TRUE has to be set in a last (extra and empty) chunk, and the optional option .__flow = TRUE can be set to get chunk dependency tracking and timing. You can track and time individual chunks, or set it as a global option to time all chunks.

An alternative to calling knit_flow is to add knitrflow::set_hooks() to an initial (uncached) chunk and knitrflow::dataflow_graph(file = "flow.RData") to the last chunk (the one with option '.__grab = TRUE'). Then the flow graph is stored in a file whenever the document is knitted. It can subsequently be loaded, plotted and further analyzed in R.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
example <- system.file("doc/example.Rmd", package = "knitrflow")
flow <- knit_flow(example)
plot(flow)
plot(flow, "manual")
summary(flow)
file.edit(example)

## End(Not run)

nielsrhansen/knitrflow documentation built on May 5, 2019, 7:59 p.m.