Column

Whoever passes the Bechdel Test, if he be worthy, shall possess the power of Thor.

Row

Proportion Passing

Bechdel Test Over the Years

---
title: "Superheroes"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source: embed
    theme: simplex
runtime: shiny

---

```{r setup, include = FALSE}
library(tidyverse)
library(plotly)
library(flexdashboard)
library(DT)



Superheroes = 
  readxl::read_excel("bechdel/Superheroes_finally.xlsx") %>% 
  mutate(
    binary = recode(binary, `FALSE` = "FAIL", `TRUE` = "PASS", `PASS` = "PASS"),
    bechdel = binary,
    title = recode(title, `Iron Man Three` = "Iron Man 3")) 
  


Superheroes_binary = 
  Superheroes %>%  
  select(title, bechdel) 



```

Column {.sidebar}
-----------------------------------------------------------------------

Data Scientists, _Assemble!_

Welcome to the Superheroes dashboard. 
Here you can explore the comparison of the Marvel Cinematic Universe with the DC 
Universe. See if your favorite superhero movies pass the Bechdel test, what 
proportion of movies from each studio pass the Bechdel test, and how the 
distribution of movies passing the Bechdel test from each studio changed over 
the years.




Column {data-width=650}
-----------------------------------------------------------------------

### Whoever passes the Bechdel Test, if he be worthy, shall possess the power of Thor. 

```{r}

datatable(Superheroes_binary, filter ='top')

```

Row
-----------------------------------------------------------------------
### Proportion Passing

```{r}
pal <- c("blue", "red")

Superheroes %>% 
  group_by(universe) %>%  
  summarise(proportion = sum(binary== "PASS")/n() * 100) %>%
  mutate(
    text_label = str_c(proportion,"%")
  ) %>% 
plot_ly(x = ~ universe, y = ~proportion, type = "bar",
          color = ~ universe,colors = pal, alpha = 0.5, text = ~ text_label) %>%
    layout(title = "Marvel Cinematic Universe vs DC Extended Universe",
         xaxis = list(title = "Studio"),
         yaxis = list(title = "% Movies Passing Bechdel Test",
                      titlefont = list(size = 9.5)),
         font = list(size = 10)
         ) %>%
  animation_opts(
    1000, easing = "elastic", redraw = FALSE
  )


```

### Bechdel Test Over the Years

```{r}

pal <- c("blue", "red")

Superheroes %>% 
  filter(binary == "PASS") %>% 
     mutate(
    text_label = str_c("Title:", title)
  ) %>% 
  plot_ly(x = ~ year, y = ~ title, type = "scatter", mode = "markers",
          color = ~ universe, colors = pal, alpha = 0.9) %>%
    layout(title = "Superhero Movies that Pass the Bechdel Test over the Years",
           titlefont = list(size = 10),
         xaxis = list(title = "Year"),
         yaxis = list(title = "Movie",
                      showticklabels = F)) 

```