6

I can't figure put how to make a book with Rmd files in a subdirectory.

Here's my current directory structure:

  • myProject.Rproj
  • index.RMD
  • _bookdown.yml
  • chapters/
    • chapt1.RMD
    • chapt2.RMD
    • extraThatShouldNotBeIncluded.RMD

What should go in _bookdown.yml and in index.RMD to make this work?

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
sharoz
  • 6,157
  • 7
  • 31
  • 57

1 Answers1

6

It turns out that you just have to specify the directory of each RMD in _bookdown.yml:

rmd_files: ["index.Rmd", "chapters/chapt1.RMD", "chapters/chapt2.RMD"]
sharoz
  • 6,157
  • 7
  • 31
  • 57
  • 1
    That is right. And there is a feature request to make it easier: https://github.com/rstudio/bookdown/issues/242 but I don't have time to think about or implement it. – Yihui Xie Jul 08 '17 at 02:28
  • 2
    Thanks @Yihui. I figured out why I was originally confused. This approach does not work when `new_session: yes`. – sharoz Jul 08 '17 at 22:55
  • @sharoz this is explained in the [book chapter on two rendering approaches](https://bookdown.org/yihui/bookdown/new-session.html) "We call these two approaches “Merge and Knit” (M-K) and “Knit and Merge” (K-M), respectively." "K-M does not allow Rmd files to be in subdirectories, but M-K does." – Paul Rougieux Feb 09 '21 at 17:03