---
title: "Evaluations Summary"
author: "Ryan Safner"
date: "11/15/2019"
output: md_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE,
                      message = FALSE,
                      warning = FALSE)
set.seed(256)
```

```{r}
library(tidyverse)
evals<-read_csv("evaluations_summary.csv")
```

```{r}

evals_year<-evals %>%
  mutate(Year=ifelse(Semester=="Spring",
                     Year,
                     Year+0.5))

```

```{r}
library(ggrepel)

years_sequence=c("2016S","2016F","2017S","2017F","2018S","2018F","2019S","2019F","2020S")

evals_year<-evals_year %>%
  mutate(Type = case_when(Num==306 ~ "Micro. Analysis",
                          Num==212 ~ "Statistics",
                          Num==480 ~ "Econometrics",
                          TRUE ~ "Econ. Elective"))
```

```{r evals-summary-overall, fig.retina=3}
ggplot(data = evals_year)+
  aes(x = Year,
      y = overall_quality_of_course)+
  geom_jitter(aes(color = Type),
              width = 0.15,
              size = 3)+
  #geom_label_repel(aes(label=stringr::str_c(Dept," ", Num)))+
  geom_smooth(method="lm", color = "black")+
  scale_x_continuous(breaks=seq(2016,2020,0.5),
                     labels=years_sequence)+
  scale_y_continuous(breaks=seq(0,5,0.5),
                     limits=c(0,5))+
  scale_color_viridis_d()+
  labs(x = "Semester",
       y = "Overall Quality of Course",
       title = "Evaluations: Overall Quality of Course",
       color = "Course Type",
       caption = "Each data point represents one course section. Data points are randomly jittered horizontally (not vertically) to avoid overplotting.")+
  theme_classic(base_family = "Fira Sans Condensed", base_size=14)+
  theme(legend.position="bottom",
        plot.caption = element_text(size = 8))
```

```{r evals-summary-teaching, fig.retina=3}
ggplot(data = evals_year)+
  aes(x = Year,
      y = overall_quality_of_teaching)+
  geom_jitter(aes(color = Type),
              width = 0.15,
              size = 3)+
  #geom_label_repel(aes(label=stringr::str_c(Dept," ", Num)))+
  geom_smooth(method="lm", color = "black")+
  scale_x_continuous(breaks=seq(2016,2020,0.5),
                     labels=years_sequence)+
  scale_y_continuous(breaks=seq(0,5,0.5),
                     limits=c(0,5))+
  scale_color_viridis_d()+
  labs(x = "Semester",
       y = "Overall Quality of Teaching",
       title = "Evaluations: Overall Quality of Teaching",
       color = "Course Type",
       caption = "Each data point represents one course section. Data points are randomly jittered horizontally (not vertically) to avoid overplotting.")+
  theme_classic(base_family = "Fira Sans Condensed", base_size=14)+
  theme(legend.position="bottom",
        plot.caption = element_text(size = 8))
```


```{r, results="asis"}
evals_table<-read_csv("../../static/evaluations/evaluations_summary.csv")
evals_table %>%
  mutate(Course = stringr::str_c(Dept, " ", Num, " (S-", Section, ")"),
         Semester = stringr::str_c(Year, "-", Semester)) %>%
  select(Semester, Course, Possible_Respondents, overall_quality_of_course, overall_quality_of_teaching) %>%
  rename(Students = Possible_Respondents,
         "Teaching (/5)" = overall_quality_of_teaching,
         "Course (/5)" = overall_quality_of_course) %>%
  arrange(Semester, Course) %>%
  knitr::kable(., format="markdown")
```