---
title: "The Bechdel Test"
author: "Your Names Here"
output:
  html_document:
    highlight: pygments
    theme: cerulean
    toc: true
    toc_float: true
---

```{r global_options, include=FALSE}
knitr::opts_chunk$set(eval = TRUE)
library(readr)
library(dplyr)
library(ggplot2)
```

## The Bechdel Test

A movie passes the Bechdel test if it satisfies 3 rules:

1. it has at least two women;
2. the women talk to each other; and
3. they talk to each other about something or someone other than a man.

The Bechdel test originated in this comic by Alison Bechdel (image source http://dykestowatchoutfor.com/the-rule): 

![](https://mhc-stat140-2017.github.io/labs/20170913_bechdel_movies/The-Rule-cleaned-up.jpg)

## Data Source

The data we're going to work with today have been gathered from a variety of sources by several people.  The Bechdel test ratings themselves are from www.bechdeltest.com, where the general public can rate movies according to whether they pass or fail the Bechdel test.  Some additional information about the movies comes from www.the-numbers.com.  These data were the basis of an article on the topic at http://fivethirtyeight.com/features/the-dollar-and-cents-case-against-hollywoods-exclusion-of-women/.  The data have since been added to the `fivethirtyeight` package for R.  I took those data, scraped some additional information about the movies like the MPAA rating, run time, and ratings from IMDB users from imdb.com.  Note that this is not a random sample of movies -- which movies made it into the data set was basically determined by which movies were rated by users of www.bechdeltest.com.  That means any findings from your analysis in this lab are only tentative.

## Initial Data Exploration

The following R chunk loads the data and sets the factor levels for categorical variables:

```{r load-data}
movies <- read_csv("https://mhc-stat140-2017.github.io/data/bechdel/bechdel.csv") %>%
  mutate(
    bechdel_test = factor(
      bechdel_test,
      ordered = TRUE,
      levels = c("nowomen", "notalk", "men", "dubious", "ok")),
    bechdel_test_binary = factor(
      bechdel_test_binary,
      ordered = TRUE,
      levels = c("FAIL", "PASS")),
    mpaa_rating = factor(
      mpaa_rating,
      ordered = TRUE,
      levels = c("UNRATED", "NOT RATED", "G", "PG", "TV-PG", "PG-13", "TV-14", "R", "NC-17"))
  )

dim(movies)

names(movies)

head(movies)

str(movies)
```

I think most of the variables are self-explanatory, but a couple require explanation.  The `bechdel_test` variable has five levels:

1. "nowomen" means there are not at least two women in the movie
2. "notalk" means there are at least two women in the movie, but they don't talk to each other;
3. "men" means there are at least two women in the movie, but they only talk to each other about men;
4. "dubious" means there was some disagreement among users of bechdeltest.com about whether or not the movie passed the test;
5. "ok" means that the movie passes the test.

The `bechdel_test_binary` variable has two levels:

1. "PASS" means that the movie passed the test (i.e., its value for `bechdel_test` is "ok")
2. "FAIL" means it did not pass the test (i.e., its value for `bechdel_test` is something other than "ok")

## Univariate Exploration

#### Make an appropriate plot of the imdb_rating variable

```{r}
# Your code goes here
```

#### Calculate the mean, median, standard deviation and IQR of the imdb_rating variable

You should use the `summarize()` function so that the result is stored in a data frame.

```{r}
# Your code goes here
```

#### Plot of bechdel_test

Make an appropriate plot of the `bechdel_test` variable.

```{r}
# Your code goes here
```

## Multivariate Exploration

#### Make an appropriate plot using the imdb_rating and bechdel_test variables

```{r}
# Your code goes here
```

#### Calculate the mean and standard deviation of the imdb_rating variable, but do it separately for each level of the bechdel_test variable

You should use the `group_by` function and the `summarize()` function so that the result is stored in a data frame.

```{r}
# Your code goes here
```


#### How would you make the plot below?

![](https://mhc-stat140-2017.github.io/labs/20170913_bechdel_movies/bechdel_plot_to_make.png)

```{r}
# Your code goes here
```

#### Make an appropriate plot using the budget_2013 and imdb_rating variables

```{r}
# Your code goes here
```

## Additional exploration

Make a few more plots of your choosing.  Try different plot types and see what relationships you can find among the variables in the data set.  Add new R chunks as needed.


