Open a new R Markdown file
Click on
File -> New File -> R Markdown...
Enter HW07: intro to R Markdown
in the
title
field.
Enter your first name in the Author
field.
Choose the HTML format
Click Ok
Save the newly created document
- Make sure to follow the file naming convention for homework
assignments
Problem 1: preliminaries
Edit the YAML header in your R Markdown file to include the
following:
- Enter your full name in the author field
- Add the code to include a table of contents with
toc_depth : 2
- Add a level 1 Header called “My level 1 header”
- Add a level 2 Header called “My level 2 header”
- Add a level 3 Header called “My level 3 header”
- click
Knit
to ensure that an html document is
created.
- Double check that the author field is correct
- Make sure that you have three headers, one of each level (1-3)
- Make sure that the table of contents at the top of your document
only includes the first two levels.
NOTE You may want to knit
your document
after you complete each problem to ensure that the out put format is
correct.
Problem 2: Lists
- Create a level 1 header titled “Problem 2: Lists”.
- Create a level 2 header titled “My favorite animals”. Then create a
numbered list, ranking your top three favorite animals.
- Create a level 2 header called “Why use R Markdown?”. Then make a
bulleted list (min 3 bullets) with a few of the benefits for using R
Markdown.
- Create a level 2 header called “Sub bulleted list”. Then create a
bulleted list (min 2 main bullets) with some of your favorite hobbies.
For each main bullet, add at least one sub bullet briefly explaining why
you like that hobby.
Problem 3: Code Chunks
- Create a level 1 header titled “Problem 3: Code Chunks”.
- Create a code chunk and set the chunk options to ensure that the
code runs but is not shown in the html document. Inside of the chunk,
copy the following line of code:
date <- Sys.Date()
- Below the code chunk created above, type “I completed this
assignment on:” and then include inline code that prints the
date
object you created in the chunk above
Problem 4: Equations
- Create a level 1 header titled “Problem 4: Equations”.
- Create an inline equation which produces the following: \(x \sim Normal(\mu = 0, \sigma = 1)\)
- hint the \(\sim\)
symbol can be added by typing
\sim
- Create a block equation for a simple linear model. Your equation
should look like this:
\[ Y = \beta_0 + \beta_1 * X \]
Problem 5: Miscellany
- Create a level 1 header titled “Problem 5: Miscellany”.
- Make a line with the following: “My CMU email address is:”. Then,
include your email address as a hyperlink.
- Include a line of text which includes at least one
bold and one italicized word. Also be sure to
include one subscript and one superscript.
Submission
Once your homework file is completed, you will need to knit the
document into an html. Be sure to go over the rendered document
to see if all the answer formats are correct.
For credit, you will submit both the .Rmd and .html files on D2L.