Permalink
Browse files

knit

  • Loading branch information...
krlmlr committed Apr 10, 2017
1 parent 1aed4c4 commit 107d23063b4d9af740d0d4a1f1af700766efeb9f
Showing with 57 additions and 1 deletion.
  1. +14 −0 08-tofu/R/knit.R
  2. +1 −0 08-tofu/README.md
  3. +35 −0 08-tofu/final.Rmd
  4. +6 −1 08-tofu/remake.yml
  5. +1 −0 README.Rmd
@@ -0,0 +1,14 @@
knit_with_deps <- function(target_name, source_name, ..., envir = parent.frame()) {
dep_names <- as.character(unlist(substitute(list(...))[-1]))
deps <- list(...)
names(deps) <- dep_names
deps <- deps[unique(names(deps))]
dep_env <- as.environment(deps)
parent.env(dep_env) <- envir
rmarkdown::render(
input = source_name,
output_format = "all", envir = dep_env
)
}
@@ -29,6 +29,7 @@
depends:
- ragout
- tofu_ragout
- final.html
```
1. Build the project, fetch the tofu ragout. The meat ragout is not recreated as part of this process (surprise!).
@@ -0,0 +1,35 @@
---
title: "Final cooking report"
author: "<Your name>"
output: rmarkdown::html_document
---
```{r init, echo = FALSE, message = FALSE}
if (!exists("ragout")) remake::create_bindings()
```
Look at the ragout I made today:
```{r}
ragout
```
I combined fried meat and vegetables:
```{r}
fried_meat
cooked_potatoes
peeled_carrots
```
Some of the components were more difficult to prepare than others:
```{r}
plot(
factor(c("Fried meat", "Cooked potatoes", "Peeled carrots")),
sapply(
list(fried_meat, cooked_potatoes, peeled_carrots),
function(x) length(format(x))
)
)
```
@@ -6,7 +6,9 @@ sources:
targets:
all:
depends: ragout
depends:
- ragout
- final.html
ragout:
command: combine(fried_meat, peeled_carrots, cooked_potatoes)
@@ -37,3 +39,6 @@ targets:
raw_potatoes:
command: buy(I("potatoes"))
final.html:
command: knit_with_deps(target_name, "final.Rmd", ragout, peeled_carrots, cooked_potatoes, fried_meat)
@@ -23,6 +23,7 @@ Please see the README files in the individual subdirectories.
```r
install.packages("remotes") # if not yet installed
remotes::install_github(c("richfitz/remake", "krlmlr/cooking"))
install.packages("rmarkdown") # optionally, for the "Reporting" exercise
```
## Test

0 comments on commit 107d230

Please sign in to comment.