| title | Your RMarkdown Thesis | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| author | Simon Goring | |||||||||||||||||||
| date | 15/09/2021 | |||||||||||||||||||
| output |
|
- Combine code & text
- Widely used plain-text format
- Output to multiple formats
- Easily tracked with
git - Works with many software tools
- Disadvantages
- Can be a pain to edit collaboratively
- "Some" learning curve
- Final product is reproducible
- You are awesome
- Can be easily shared, modified & updated
-
Or open our file. . . see GIF here
- Navigate to the repository for this workshop
- Fork the repository see video
- Start a project from Version Control
- Link to ThesisIsCode
- Open the file in
thesis/myThesis_Revised.Rmd
-
Folders!
- Figures (raw, finished); Code; Data (input/output); Save Google Sheet to file.
- YAML header (metadata for the document)
- Markdown formatting
- Fenced code blocks (using backticks)
- Data import
- Analysis
- Conclusions
- YAML Ain't Markup Language
- Tells Pandoc how to render the finished file.
---
title: Some title
author: Simon Goring
---- Any tags are accepted (
date,abstract,keywords)
---
title: Some title
author:
- Simon Goring
- Socorro Dominguez
abstract: >
I can move stuff to a new line.
---- Any tags are accepted (
date,abstract,keywords)
---
title: Some title
author:
- Simon Goring
- Socorro Dominguez
abstract: >
I can move stuff to a new line.
---Format specific options for html, pdf, Word, &cetera.
- How you actually apply styles/links &cetera
- Good Markdown Resources:
- This is the R part of RMarkdown. R executes the code and places it inline into the text.
Here is writing
```{r namedCodeBlock}
this <- is(code)
```
Here is writing that uses `r this` result.
Rscript -e "rmarkdown::render('filename.Rmd')"Or, with bash (Mac & Linux) you can build on save.
- We can knit to PDF, HTML, DOCX (and other formats)
- Options depend on options in the
yamlheader (in part) - RMarkdown
render:- Runs each R code block
- Creates a raw Markdown file
- Replaces code with code results (knits)
- Converts file format to desired output with Pandoc
- Lets load in our file in
thesis/data/input:
```{r loadData}
table <- read.csv('data/input/GitHubRepos.csv')
```
The table has `r nrow(rows)`, but there are less READMEs than a dozen eggs.
- Are there errors we can fix?
- We need to check our assumptions
- Formalize them with
assertthat()
- We want to make sure our text follows from our analysis.
```{r loadData}
table <- read.csv('data/input/GitHubRepos.csv')
```
The table has `r nrow(rows)`, but there are less READMEs than a dozen eggs.
- But are there?
assertthat::assert_that(sum(!is.na(table$README)) < 12, msg="There are more readme's than a dozen eggs.")- If the assertion fails then the code doesn't
knitand you have an informative error message telling you why.
- You've created a thesis chapter.

