---
title: "Quarto_template"
subtitle: "HTHSCI 1M03: Foundations of Data Science"
author: Put_your_name_here
date: now
date-format: full
## Code chunk
execute: 
  eval: true
  echo: true
knitr:
  opts_chunk:
    ## Code
    comment: "#>"
    collapse: true
    ## Figures: R4DS 28.6
    fig-width: 6 
    fig-asp: 0.618
    out-width: "70%"
    fig-align: center
## References
bibliography: ./Lecture_3_ref.bib
csl: ./Lecture_3_apa.csl
format: pdf
---

```{r setup}
#| include: false
library(tidyverse)
library(gt)
set.seed(34)
```

* The `setup` code chunk has `#| include: false`
  + Runs the code and suppresses everything else.
  + See the table in section [28.5.2](https://r4ds.hadley.nz/quarto#chunk-options) of R4DS.

:::{.callout-note}
The `setup` code chunk is where you load your `R` packages and set your random number seed.
:::

* Above is an example of a [callout block](https://quarto.org/docs/authoring/callouts.html). 

# Document Header

## `R` Code chunk: evaluated, not echoed

* Loads the `iris` data.
* The loading is not visible in the `pdf` document.

```{r}
#| echo: false
data(iris)
```

## `R` Code chunk: not evaluated, echoed

```{r}
#| eval: false
data(olive, package = "dslabs")
```

- The `R` code above is displayed in the `pdf` file but **not** run/evaluated $\Rightarrow$ the `olive` data is not loaded into the `R` environment.

## R Code chunk: evaluated and echoed

```{r}
iris |>
  group_by(Species) |>
  summarize(mean_p_len = mean(Petal.Length)) |>
  gt() |>
  fmt_number(columns = mean_p_len, decimals = 1) |>
  cols_label(mean_p_len = "Mean Petal Length")
```

* The `R` code chunk has no options.
  + It is being controlled by the global `execute:` options in the YAML header.  

\newpage

## R plot

```{r sample_plot}
#| fig.cap="Sample Graph"
iris |>
  ggplot(aes(x = Petal.Length, y = Petal.Width, color = Species)) +
  geom_point() +
  labs(x = "Petal length", y = "Petal width", color = "Species") +
  theme_minimal() +
  theme(legend.position = "bottom")
```

* Looks like `setosa` is different from the other two species.

* We used the `R` code chunk option `#| fig.cap=""`  to add the figure caption.

\newpage

# Reference Examples

:::{.callout-important}
You will need to know how to do this for the project.
:::

## Example

Our textbook, @irizarry2019 does a nice job explaining data visualization principles.

## Instructions

* To add the book reference above, include _\@irizarry2019_ in your `.qmd` file.
  + \@ indicates the following text is a reference.
  + _irizarry2019_ is the name of the books entry in `Lecture_3_ref.bib` $\Rightarrow$ `\@Book{irizarry2019,`
* The YAML header contains references to `Lecture_3_ref.bib` and `Lecture_3_apa.csl`.
  + `Lecture_3_ref.bib` contains the BibTeX entries for your references. 
  + `Lecture_3_apa.csl` styles your references using the APA citation style.
* The easiest way to populate your *.bib file is to use Google scholar.
  + click on the _"_ or the _Cite_ icon to find the BibTeX entry for your paper or book. 

* See the following links for more details:
  1. [Citations & Footnotes](https://quarto.org/docs/authoring/footnotes-and-citations.html)
  2. [Citation Style Language (CSL) styles](https://github.com/citation-style-language/styles)


## References
