ulyngs / oxforddown

Template for writing an Oxford University thesis in R Markdown; uses the OxThesis LaTeX template and was inspired by thesisdown.
https://ulyngs.github.io/oxforddown/
MIT License
221 stars 81 forks source link

Question on understanding-this isn't an issue, so please delete if you prefer! #11

Closed GabriellaS-K closed 3 years ago

GabriellaS-K commented 3 years ago

Hi! Thank you for your excellent guide to oxford down. The YouTube videos and help pages are incredibly helpful. Please forgive the v basic question. I have recently started using R bookdown, to try write papers (and ultimately my thesis, at Oxford). I've read the cookbook and book down guide, as well as your files and the others you link to. I use rmardown, and understand that, but I don't understand how bookdown 'knows' what to put together.

As instructed by the helpsheets, I have several chapters:

Normally in rmarkdown, every new file I open, I have a 'r set up' chunk where I set the initial global decisions for the doc (echo=TRUE for example). I also install and load all packages I need for that specific document. Do I still need to do this in bookdown? Or do I do it only once in the index chapter? I just don't quite understand what to put in index and what not to put in the other chapters.

Graphs/Tables: If I create a graph in chapter 3 can I put it in chapter 2? Or does it render in order of chapters, and is the better way to have a separate file for all the code for my graphs? I need to find a good way to integrate the writing with the stats, would you do each of these in separate files?

Thanks so much

ulyngs commented 3 years ago

Hi Gabriella,

the answer to your question is here: https://bookdown.org/yihui/bookdown/new-session.html

By default, the thesis is built with the 'merge and knit' approach. I.e., all the rmd files are combined into one massive rmd file. This is done in alphabetical order, unless you manually specify the order in _bookdown.yml.

This massive rmd file is then knitted. So if a variable is created in an earlier chapter, you can refer to it in a later chapter. And global chunk options set in an earlier chapter will carry over to later chapters.

You can change instead to a 'knit and merge' approach by including a line that says 'new_session: yes' in _bookdown.yml. In this case, each of the chapters are first knitted independently of each other, and then merged afterwards.

I'll add a 'how it works' chapter to the sample content at some point.

ulyngs commented 3 years ago

Also, on organisation have a look at this chapter in the R Markdown Cookbook: https://bookdown.org/yihui/rmarkdown-cookbook/managing-projects.html

GabriellaS-K commented 3 years ago

Hi Gabriella,

the answer to your question is here: https://bookdown.org/yihui/bookdown/new-session.html

By default, the thesis is built with the 'merge and knit' approach. I.e., all the rmd files are combined into one massive rmd file. This is done in alphabetical order, unless you manually specify the order in _bookdown.yml.

This massive rmd file is then knitted. So if a variable is created in an earlier chapter, you can refer to it in a later chapter. And global chunk options set in an earlier chapter will carry over to later chapters.

You can change instead to a 'knit and merge' approach by including a line that says 'new_session: yes' in _bookdown.yml. In this case, each of the chapters are first knitted independently of each other, and then merged afterwards.

I'll add a 'how it works' chapter to the sample content at some point.

Thank you so much, these links are helpful. I now understand the MK vs KM approach, but I'm not sure I understand which approach is better to reference graphs/tables between chapters?

ulyngs commented 3 years ago

The default MK approach would generally be better because everything's knitted in the same session, so you can be sure stuff in one chapter knows about stuff in other chapters. However, try playing around with it!