2 Computing setup
2.1 Bookdown
I’m creating this notebook in bookdown. I ran into a number of poorly documented issues.
- To use the build tab, you need to go into the Rproj file and set build type to “Website.” In addition, you need to make sure that the lines
knit: "bookdown::render_book"
,site: "bookdown::bookdown_site"
, andoutput: bookdown::gitbook
are in the yaml header (either in index.Rmd or, presumably, _bookdown.yml) - I’m trying to suppress the chapter/section numbers, and only show top-level stuff in the toc. There’s a proposed solution here but that doesn’t seem to be working (I don’t know where to put the json file referenced there).
- I’d hoped not to have subsections display in the sidebar. Sometimes the subsections only show in the currently selected chapter, but that seems not to be consistent behavior.
Individual content files should be named with the date, in format yyyy-mm-dd.Rmd. The first line should also include the date, in the format, e.g., # (PART) 7 April 2017 {-}
. This creates a “part” with the date, and all subjects within the day’s work can be top-level headers.
As the notebook gets longer I’ll want to start making good use of preview_chapter()
, but it does not (by default) display the page. I’ll need to figure out how to get that working…
I’ll also want to set up a template file, especially once I decide what needs to go into the preamble for R code execution.
I need to look through the bookdown documentation to see what else I can set in _bookdown.yml
. A good place to start is the Configuration chapter of Authoring Books with R Markdown. It may be that I can put the index.Rmd file in the project root, and the entries in a subdirectory specifed by rmd_subdir
, and have the working directory for the Rmd files be the project root.
Just for grins, let’s see what the working directory is set to:
getwd()
## [1] "/Users/Bkendall/Documents/github-bitbucket/InvasionHet/notebook"
- With a “standard” setup (the index.Rmd being in
notebook
) it gives the notebook directory. - After moving
index.Rmd
and_bookdown.yml
to the project root, and addingrmd_subdir: true
to the latter, I get the project root as the working directory. This is good! However, it appears that this will lead to Rmd files in all subdirectories getting included. Unless I can use regular in thermd_files
option this will be a dealbreaker eventually. I haven’t found any way to do the latter.
Let me try moving everything back to the notebook directory and applying setwd():
setwd("..")
getwd()
## [1] "/Users/Bkendall/Documents/github-bitbucket/InvasionHet"
This seems to work.
I won’t want R code from old entries re-running, not just for time but because data and functions may have changed. I think the key here is to:
- Use the K-M approach by putting
new_session: yes
in_bookdown.yml
- Set cache on for everything (i.e., in the knitr options set in the index file).
But this is incompatible with having Rmd files in subdirectories!!!!
In principle, it may save compilation time to have files without R code simply be md files. But it seems that only Rmd files are searched by default; md files would need to be added by hand to rmd_files
.
2.2 ProjectTemplate
I also set up the directory structure using ProjectTemplate. The one tricky thing is that Rmd files in this notebook (and in the reports directory as well) may have to chdir to the root, which might be tricky. If I keep the index file in the root as described above then this shouldn’t be a problem.