---
title: "Lab 7.1 - Faculty Hiring Patterns"
author: "Author Goes Here"
date: "Semester Goes Here"
output:
  html_document:
    code_download: true
---

```{r setup, include = FALSE}
# Set some useful chunk options for code chunks.
knitr::opts_chunk$set(
  echo = TRUE,
  error = TRUE,    # display errors but keep going.
  comment = "",    # don't add '##' characters before output.
  message = FALSE  # don't include messages in the knitted output (check them in RStudio)
  )
library(tidyverse)
theme_set(theme_bw())
```

This document explores the claim that universities are increasingly hiring more part-time faculty and less full-time faculty. It starts with a rather poorly designed plot, which shows the trend but only at the cost of some considerable effort on the part of the reader, and improves the visualization, which shows the trend more clearly.

## Analysing the Original Visualization

The American Association of University Professors (AAUP), a nonprofit membership association of faculty and other academic professionals, created [this report](https://www.aaup.org/sites/default/files/files/AAUP_Report_InstrStaff-75-11_apr2013.pdf). The report discusses trends in instructional staff employees between 1975 and 2011, and contains a visualization very similar to this one:

![Instructional staff employment trends](https://cs.calvin.edu/courses/info/601/07tidy/lab/images/staff-employment.png){width="700px"}

🚧
Analyze this plot: what type of plot is it? What variables are mapped to what aesthetics? What is easy to see, what is hard to see?

## Designing Alternate Visualizations

🚧
Sketch on paper two alternative designs for this plot that might do a better job of illustrating the hiring levels different types of faculty over time. Describe the alternatives in the same way as you just did above (type, aesthetic mappings) and explain how they might be improvements of the original.

## Rebuilding the Visualization

We now update the visualization incrementally, starting with an approximation of the original.

### 1. Reproduce the original plot.

🚧
Remake the original plot, starting with [this dataset](https://cs.calvin.edu/courses/info/601/07tidy/lab/data/instructional-staff.csv) and trying to make it look as follows.

![aaup-1](https://cs.calvin.edu/courses/info/601/07tidy/lab/images/aaup-1.png)

Notes:

- The dataset will need to be pivoted, so that you have columns for `faculty_type`, `year`, and `percentage`.
- Use a column chart with dodged bars (`geom_col(position = "dodge")`).
- Use the Viridis color scale (`scale_fill_viridis_d()`)
- Include labels (`labs()`) for: `x`, `y`, `fill`, `title`, `caption`

### 2. Convert to a stacked bar plot.

We'd like to more directly compare the hiring levels of the different faculty types.

🚧
Update the plot to look like this.

![aaup-2](https://cs.calvin.edu/courses/info/601/07tidy/lab/images/aaup-2.png)

Notes:

- See if you can do this without repeating the `pivot_longer`.
- We used `theme_minimal()`.

### 3. Convert to a line plot.

Line plots tend to be good for view values over time.

🚧
Update the plot to look like this.

![aaup-3](https://cs.calvin.edu/courses/info/601/07tidy/lab/images/aaup-3.png)

Notes:


- Note the use of a redundant encoding (`shape`). I had to add a `geom_point` layer to draw those.
- Note that, at first, the lines don't actually show up. You can hack you way to make it work by adding `group = year` to the aesthetic mappings; a Google search on the error message you get will probably get you there. But that yields the plot shown above. If you look carefully, you'll see something badly wrong with it.
- Once you notice what's wrong with the line plot, then fix things by making sure that the year is treated `as.numeric`. (And once you do that, you don't need the `group = year` hack anymore anyway.)
- If you made changes to earlier code, make sure your earlier plots still work. (You may need to replace `year` with `factor(year)` in those plots, depending on how you did it.)

### 4. Just show the numbers.

Sometimes, simply displaying numbers is as effective as visualizing them. Let's make the *table* below, which shows the changes in hiring levels, i.e., the 2011 percentage minus the 1975 percentage.

🚧

- First, make the table the easy way, starting with `staff`. Tip: `2011` isn't normally a valid variable name, but you can use backticks (next to the 1 key): `` `2011` ``. You'll probably need to `select` some columns.
- Once you have the resulting table, can you now make the same thing but starting with your *long*-format data?
  - Yes, you'll need to pivot.
  - Can you do write this pipeline without using `select()`? Hint: I think that `select` and `filter` should have been called `select_columns` and `select_rows`.

<table>
<thead>
<tr class="header">
<th align="left">faculty_type</th>
<th align="right">1975</th>
<th align="right">2011</th>
<th align="right">change</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">Full-Time Tenured Faculty</td>
<td align="right">29.0</td>
<td align="right">16.7</td>
<td align="right">-12.3</td>
</tr>
<tr class="even">
<td align="left">Full-Time Tenure-Track Faculty</td>
<td align="right">16.1</td>
<td align="right">7.4</td>
<td align="right">-8.7</td>
</tr>
<tr class="odd">
<td align="left">Full-Time Non-Tenure-Track Faculty</td>
<td align="right">10.3</td>
<td align="right">15.4</td>
<td align="right">5.1</td>
</tr>
<tr class="even">
<td align="left">Part-Time Faculty</td>
<td align="right">24.0</td>
<td align="right">41.3</td>
<td align="right">17.3</td>
</tr>
<tr class="odd">
<td align="left">Graduate Student Employees</td>
<td align="right">20.5</td>
<td align="right">19.3</td>
<td align="right">-1.2</td>
</tr>
</tbody>
</table>

Notes:

- You can format the table by piping the resulting dataframe through `knitr::kable()`.

## Drawing Conclusions

🚧
In conclusion, are universities hiring more part-time faculty and less full-time faculty? Why might this be?
