Comparing the IMDB rating before a movie being named to the Oscar and after.

library(ggplot2)
## 
## Attaching package: 'ggplot2'
## 
## The following object is masked _by_ '.GlobalEnv':
## 
##     movies
library(dplyr)
## 
## Attaching package: 'dplyr'
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyr)
require(scales)
## Loading required package: scales
source("oscar-lib.R")

nominations <- read.csv("Data/Oscar-Nominations.csv")
movies <- read.delim("latest/newmovies.dat", header=FALSE)
movies_ratings <- read.delim("latest/newratings.dat", header=FALSE)
colnames(movies) <- c("movie_id", "movie_title", "genre")
colnames(movies_ratings) <-  c("user_id", "movie_id", "rating", "rating_timestamp")

oscar_nominations_2013 = 1389830400
oscar_nominations_2014 = 1421280000

oscar_2013 <- mean_before_after(movies_ratings, 2013, oscar_nominations_2013, nominations)
oscar_2014 <- mean_before_after(movies_ratings, 2014, oscar_nominations_2014, nominations)

plot <- oscar_2013 %>%
  gather(type, ratings, ratings_before:ratings_after)

p <- ggplot(data=plot, aes(x= name, y=ratings, fill=type)) + 
  geom_bar(stat="identity", position=position_dodge()) + 
  labs(y='Ratings', x='Movies', title = "2013") + 
  theme_classic() + 
  theme(axis.ticks = element_blank(), axis.text.x = element_text(angle = 45, hjust = 1), panel.background=element_blank()) +
  scale_fill_manual(values=c("#edf8b1", "#7fcdbb"))

p

plot <- oscar_2014 %>%
  gather(type, ratings, ratings_before:ratings_after)

p <- ggplot(data=plot, aes(x= name, y=ratings, fill=type)) + 
  geom_bar(stat="identity", position=position_dodge()) + 
  labs(y='Ratings', x='Movies', title = "2013") + 
  theme_classic() + 
  theme(axis.ticks = element_blank(), axis.text.x = element_text(angle = 45, hjust = 1), panel.background=element_blank()) +
  scale_fill_manual(values=c("#edf8b1", "#7fcdbb")) 

p

2013

month <- c("Oct", "Nov", "Dec", "Jan", "Feb", "Mar", "Apr")
num <- c(1,2,3,4,5,6,7)
timestamp <- c(1381881600,1384560000,1387152000,1389830400,1392508800,1394928000,1397606400)
df = data.frame(month, num, timestamp)  

toPlot <- mean_before(movies_ratings, df, 2013, nominations)

ggplot(data = toPlot, aes(x=reorder(month, num), y = ratings, group=name,  colour=name)) + 
  geom_line() +
  geom_point() + 
  scale_colour_manual(values = c(alpha("#999999", 1), 
                                 alpha("#f781bf", 1),
                                 alpha("#a65628", 1),
                                 alpha("#ffff33", 1), 
                                 alpha("#ff7f00", 1),
                                 alpha("#984ea3", 1), 
                                 alpha("#4daf4a", 1),
                                 alpha("#377eb8", 1), 
                                 alpha("#e41a1c", 1)),                                
                      guide = guide_legend(title = "Partido", 
                                           override.aes = list(alpha = 1, size = 4))) +
  ylab("Ratings") + xlab("Month") +  
  theme_classic() + 
  theme(axis.ticks = element_blank())