buildChapterGraph: Build the chapter dependency graph

View source: R/buildChapterGraph.R

buildChapterGraphR Documentation

Build the chapter dependency graph

Description

Build the dependency graph between chapter based on their extractCached calls to each other.

Usage

buildChapterGraph(dir, recursive = TRUE, pattern = "\\.Rmd$")

Arguments

dir

String containing the path to the directory containing Rmarkdown reports. This is searched recursively for all files ending in ".Rmd".

recursive, pattern

Further arguments to pass to list.files when searching for Rmarkdown reports.

Value

A directed graph object from the igraph package, where each node is a chapter and is connected to its dependencies by an edge.

Author(s)

Aaron Lun

Examples

dir <- tempfile()
dir.create(dir)

tmp1 <- file.path(dir, "alpha.Rmd")
write(file=tmp1, "```{r, echo=FALSE, results='asis'}
rebook::chapterPreamble()
```

```{r}
rodan <- 1
```")

tmp2 <- file.path(dir, "bravo.Rmd")
write(file=tmp2, "```{r, echo=FALSE, results='asis'}
rebook::chapterPreamble()
```

```{r}
extractCached('alpha.Rmd')
```")

# Building the chapter graph:
g <- buildChapterGraph(dir)
plot(g)
 

LTLA/rebook documentation built on June 5, 2023, 6:24 p.m.