"Missing files for target" error using Drake for Rmd

391 Views Asked by At

Been learning how to use Drake today and managed to migrate my code but not my R markdown reports yet. This report compiles fine, and produces the expected output, but also gives this error which no amount of searching has shed light on.

Error message from drake

I am using the r_make() command as recommended, and my plan so far reads:

plan_0 <- drake_plan(
  raw_c_data = read_rds(
    file_in("data/css_carib_data.rds")),
  raw_c_fg = read_rds(
    file_in("data/css_carib_fg.rds")),
  c_data = clean_caribbean_fg(raw_c_data, raw_c_fg),
  clean_c_fg = write_rds(
    c_data,
    file_out("data/clean_c_fg.rds"),
    compress = "gz"),
  c_maps = gen_maps(bbx_1, bbx_2, bbx_3, bbx_4, bbx_5),
  c_maps_out = write_rds(
    c_maps,
    file_out("data/c_maps.rds"),
    compress = "gz"),
  c_base_report = rmarkdown::render(
    knitr_in("R/0_prepare_data.Rmd"),
    output_file = file_out("0_prepare_data.html"),
    quiet = T)
)

That Rmd file starts with the following

---
title: "0: Data Description"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

require(drake)
require(tidyverse)
require(ggmap)

loadd(raw_c_fg)
loadd(clean_c_fg)
loadd(c_maps)
```

This document is a description of the data processed in `0_prepare_data.R` from the Caribbean region. The following table gives the counts of each classification within the aggregated functional groups.

```{r tables, echo = F}
raw_c_fg %>%
  pull(fg) %>%
  table() %>%
  knitr::kable(col.names = c("Class", "Count"),
               caption = "Counts of Each Functional Group")
```

I'm happy to attach as much more as required, but hopefully this is enough to see why I am getting this error?

1

There are 1 best solutions below

0
On BEST ANSWER

Figured out what was going wrong, and it was the usual conflict between Rmd and Rproj/drake with relative locations. I had located the Rmd file within the R directory, but _drake.R was in the base directory, and so the differences in locating the output were causing drake to look in the wrong place.