Assignment #12 - R Markdown
For this week's assignment, we were tasked with learning the basics of R Markdown authoring and document structure by practicing embedding R code, narrative text, and LaTeX math in a single file. Here are some of the things I learned:
- While building this document, I learned that Markdown has specific syntax to follow. Including "##" will generate a small header, and any text written without that will display in a paragraph font. To create a code chunk, you have to encase it in ``` ```, and include {r chunk_name}. If you want to hide the code in the rendered output, you would write it as {r chunk_name, include=FALSE}. The code chunk generated with the document (shown below) essentially creates a rule that the R code will be displayed in each chunk by default after knitting.
- LaTeX math has two modes, inline or display. The inline equation mode uses a single $ on each end of the equation (e.g., $a^2 + b^2 = c^2$), whereas the displayed mode uses two $$ on each end (e.g., $$a^2 + b^2 = c^2$$) to separate the equation from the text and place it on its own centered line.
- Code chunks and narrative sections can be written without any line breaks, but require the ``` ``` to encase a code. If that is not done, it will be read as either one full code or all narrative.
- As for any challenges I faced, I did notice that I had to go back and forth between editing my document and knitting to see the rendered output, specifically because I chose to hide my code chunks in the output. Additionally, there were slight formatting issues that I wanted to correct, which could only be seen in the output. One error I encountered was not individually labeling each code chunk that I wrote. I was unaware that knitr would not be able to decipher between code chunks that were not uniquely labeled, so I received an error.
Comments
Post a Comment