---
title: "UC R Markdown Template"
author: "Saannidhya Rawat"
date: "`r format(Sys.Date(), '%B %e, %Y')`"
output:
  Rbearcat::UC_html_document: default
  Rbearcat::UC_pdf_document: default
  Rbearcat::UC_word_document: default
bibliography: "references.bib"
biblio-style: "apalike"
link-citations: true
mainfont: Open Sans
fontsize: 12pt
---


```{r setup, echo=FALSE, message=FALSE, warning=FALSE}
options(kableExtra.latex.load_packages = FALSE)

# load packages
library(Rbearcat)
library(tidyverse)
library(lubridate)
library(haven)
library(stringr)
library(here)
library(knitr)
library(janitor)
library(scales)
library(viridis)
library(RColorBrewer)
library(kableExtra)
library(flextable)
# include additional packages here (if needed)
# library(DT)
# library(ggrepel)

# set default Rmd options
Rbearcat::bcat_setup_rmd()

# set default UC geoms
Rbearcat::set_UC_geoms()

# output type
doc_type <- knitr::opts_knit$get('rmarkdown.pandoc.to')

```

```{r logo, out.width="50%"}

# if(!knitr::is_latex_output()){
#   
#   knitr::include_graphics(here::here("logo.png"))
#   
# }

```

# First Level Header

Some *italized text*. Some **bold text**.

A list:

* item 1
* item 2
  * sub-item 1
  * sub-item 2.2

A numbered list.

1. item 1
2. item 2
3. item 3

# Figures generated by R:

```{r line-plot, fig.cap="A Line Plot"}

# using function from Rbearcat package
Rbearcat::bcat_plt_line(df = economics,
                     x = date,
                     y = unemploy)

```

```{r bar-plot, fig.cap = "A Bar Plot"}

# using ggplot2, but adding custom theme from Rbearcat package
iris %>%
  dplyr::group_by(Species) %>%
  dplyr::summarise(sepal_length_mean = mean(Sepal.Length)) %>%
  ggplot2::ggplot(ggplot2::aes(x = Species, y = sepal_length_mean)) +
  ggplot2::geom_col(fill = Rbearcat::palette_UC["UC Red"]) +
  ggplot2::coord_flip() +
  Rbearcat::theme_UC_vgrid()

```

```{r scatter-plot, fig.cap = "A Scatter Plot", out.width="100%", fig.width=8.57}

# using function from Rbearcat package
Rbearcat::bcat_plt_point(iris,
                      x = Sepal.Length,
                      y = Sepal.Width,
                      color = Species,
                      facet = vars(Species),
                      smooth = TRUE)

```

# A nicely formatted table:

```{r table}
Rbearcat::bcat_fmt_style_table(iris[1:10,])
```

# Inline dynamic text

```{r setosa-mean}

setosa_mean_length <-
  iris %>%
  dplyr::group_by(Species) %>%
  dplyr::summarise(sepal_length_mean = mean(Sepal.Length)) %>% 
  dplyr::filter(Species == "setosa") %>% 
  dplyr::pull()

```

The mean sepal length for the setosa species is `r setosa_mean_length`.

# Some math 

A vector of observations $y$ having $n$ components is assumed to be a realization of a random variable $Y$ whose components are independently distributed with means $\mu$.

In the original formulation of GLMs, the assumed distribution of $Y$ is a member of an *exponential family* which have a probability density function of form:

$$f(y_i) = exp\{\frac{y_i\theta_i - b(\theta_i)}{a_i(\phi)} + c(y_i, \phi)\}$$

where $\theta_i$ and $\phi$ are parameters and $a(\cdot)$, $b(\cdot)$, and $c(\cdot)$ are known functions.

# Technical Notes

This document was written in R Markdown, using the `rmarkdown` [@xie-markdown] and `knitr` [@xie-knitr] packages.

# References
