Course evaluation is now open! It will be closed on Tuesday, June 21 at 11:59pm. If more than 80% of you complete the evaluation, everyone will receive a bonus point!
Check your emails or visit duke.evaluationkit.com to complete the evaluation.
Clone the repository entitled “ae24-GitHubUsername” at course GitHub organization page on your RStudio.
Open the .Rmd
file.
Refer to STA199: Final Project - Tips for general guidelines for formatting of your report.
In order to make bullet points, skip a line and use a hyphen -
.
function
or variable
tab
once for a sub-listlinks-as-notes: TRUE
to YAML to display URLs as a footnote in the knitted PDF.fontsize: 11pt
to YAML.Your report will include citations about the data source, previous research, and other sources as needed. At a minimum, you should have a citation for the data source.
Follow the steps below to easily include citations in your report:
.bib
file. All of your bibliography entries will be stored in it. Let’s take a look at references.bib
.Q - Add a bibliography entry for the book R markdown: The definitive guide to references.bib
.
references.bib
.Include bibliography: references.bib
in the YAML.
At the end of the report, include ## References
. This will list all of the references at the end of the document under the section “References”.
If you want to include an Appendix after References, include the additional code shown at the end of this document.
Here are examples of different in-text citations:
Q - Add a citation for R markdown: The definitive guide in the sentence below.
The following code chunk is adapted from ______.
Code chunk options are used to customize how the code and output is displayed in the knitted R Markdown document. There are two ways to set code chunk options:
A few options to change what we show / hide in the knitted document:
message = FALSE
to hide messages.warning = FALSE
to hide warnings (with caution!)
warning = FALSE
.echo = FALSE
to hide code.
echo = FALSE
to hide all code in your final report.include = FALSE
to run code but hide code, output, messages, warnings, etc.
eval = FALSE
to not run code.
Q - Clean up the mess below.
knitr::opts_chunk$set(message = TRUE,
warning = TRUE,
echo = TRUE,
fig.width = 6, # width of figure
fig.asp = .618, # aspect ratio of figure
out.width = "70%", # width relative to text
fig.align = "center" # figure alignment
)
library(knitr)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.7 ✔ dplyr 1.0.9
## ✔ tidyr 1.2.0 ✔ stringr 1.4.0
## ✔ readr 2.1.2 ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
theme_set(theme_bw()) # set global theme
Q - Try echo = FALSE
and take a look at the updated PDF.
For ggplots
, you can set a global theme (see the code chunk above). Click here to explore available themes and choose your favorite. In case your PDF is printed, gray or dark background for plots are not recommended.
You can also set a color theme of your choosing. You can call any color by any name you would like in my_palette
.
Q - Add “dukeblue” in my_palette
. Hint: Find hex code.
mpg %>%
ggplot(aes(y = manufacturer, fill = drv)) +
geom_bar()
We can do better than this.
Q - Incorporate the following recommended changes in the plot.
my_palette
.Calculate mean, median, and standard deviation of cty
.
mpg %>%
summarize(mean_cty = mean(cty), median_cty = median(cty), sd_cty = sd(cty))
## # A tibble: 1 × 3
## mean_cty median_cty sd_cty
## <dbl> <dbl> <dbl>
## 1 16.9 17 4.26
We can also do better than this.
Q - Incorporate the following recommended changes in the table.
These notes were adapted from the following: