Skip to content

Commit

Permalink
Merge pull request #73 from fmichonneau/knitr_fig_path
Browse files Browse the repository at this point in the history
add function knitr_fig_path
  • Loading branch information
Greg Wilson authored and GitHub committed Jul 2, 2016
2 parents fb17830 + 634e055 commit 06c8f26
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bin/chunk-options.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ library("knitr")

fix_fig_path <- function(pth) file.path("..", pth)


## We set the path for the figures globally below, so if we want to
## customize it for individual episodes, we can append a prefix to the
## global path. For instance, if we call knitr_fig_path("01-") in the
## first episode of the lesson, it will generate the figures in
## `fig/rmd-01-`
knitr_fig_path <- function(prefix) {
new_path <- paste0(opts_chunk$get("fig.path"),
prefix)
opts_chunk$set(fig.path = new_path)
}

## We use the rmd- prefix for the figures generated by the lssons so
## they can be easily identified and deleted by `make clean-rmd`. The
## working directory when the lessons are generated is the root so the
Expand Down

0 comments on commit 06c8f26

Please sign in to comment.