1. Adding and formatting text
Let's discuss another Markdown file element, the text.
2. Including text in a report
Within a report, we can include a discussion of the data that is presented by adding text.
3. Headers
Including headers in the report will help clearly label each section. We add headers using a hash and a single space before the text. The more hashes we use, the smaller the header will be.
4. Adding headers
Here we use two hashes for the section called Datasets, and three to label each dataset, Investment Annual Summary and Investment Services Projects.
Remember to place the hash at the start of the line and add a single space after the hash before the text. If you include a space or another character before the hash, the header won't render.
Notice that the size of each header in the knit file is determined by the number of hashes before the text.
5. Sentences
We can include sentences to add additional detail to the report. Here, we add sentences to describe each dataset.
6. Adding sentences
Recall, the code chunks are what separate the text from the code in the report once it's knit, so we'll want to include this text outside of any code chunks.
The added sentences are included after the header but before the code chunk, so that when we knit the report, the reader will see
7. Adding sentences
the headers,
8. Adding sentences
dataset description,
9. Adding sentences
and code in the intended order.
10. Code comments
If we want to include text within the code, we add a single hash before the text. This renders the text as a code comment within the code chunk. We'll discuss how and when to include code in the report later in the course.
11. Formatting text
There are many options for formatting text in a markdown file, including making the text bold, italicized, or strikethrough.
To bold the text, we surround it with two sets of asterisks or underscores. To italicize it, we use one set of asterisks or a single set of underscores, and to strikethrough text, we surround the text with two sets of tildes.
12. Inline code
We can also add inline code to the text to clarify that we are referring to object names from the code.
Let's edit the sentences about the datasets to reference the code that defines them. We add inline code by surrounding the text with a single set of backticks.
13. Inline code
When we knit the file, the dataset names are formatted as code and the audience knows that we are referring to code within the sentence.
14. Including links
We can also add website links to the report. Here, we reference the data source by placing the link text in square brackets followed by the link in parentheses. Note, there are no spaces between the square brackets and the parentheses.
15. Including images
Images are added similarly, except we place an exclamation mark in front of the square brackets. The images we reference in the parentheses can be either local files or images from the web.
16. Summary
To summarize, we can add headers by placing hashes in front of text. The more hashes we use, the smaller the header will be.
We add inline code with a single set of backticks. We can bold text with two sets of asterisks or underscores, italicize with one set of asterisks or underscores, or strikethrough with two sets of tildes.
We place a single hash in front of text within a code chunk to render it as a code comment.
We can add website links by placing the link text in square brackets and the link in parentheses. Images are added similarly, except they have an exclamation mark in front of the square brackets.
17. Let's practice!
Let's practice!