1 Introduction

Bagi penggila film, khususnya film. Tentu tidak asing dengan situs TMDb. TMDb merupakan situs web yang menyediakan informasi mengenai film dari seluruh dunia, termasuk orang-orang yang terlibat di dalamnya mulai dari aktor/aktris, sampai sutradara. Dataset dalam analisis ini menggunakan dua buah dataset, yaitu dataset movies dan dataset credits. Visualisasi apa saja yang dapat kita rangkum dalam analasis ini. Mari segera mulai!!

2 Loading the data and summary

Pertama, masukkan data dan panggil library yang akan digunakan dalam analisis visualisasi. Lanjutkan dengan melihat dataset yang ada. Lakukan pengamatan dan pilih apa saja yang akan di analisis.

library(plyr) #data manipulation
library(tidyverse)# data manipulation
## -- Attaching packages --------------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.2.0       v purrr   0.3.2  
## v tibble  2.1.3       v dplyr   0.8.0.1
## v tidyr   0.8.3       v stringr 1.4.0  
## v readr   1.3.1       v forcats 0.4.0
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::arrange()   masks plyr::arrange()
## x purrr::compact()   masks plyr::compact()
## x dplyr::count()     masks plyr::count()
## x dplyr::failwith()  masks plyr::failwith()
## x dplyr::filter()    masks stats::filter()
## x dplyr::id()        masks plyr::id()
## x dplyr::lag()       masks stats::lag()
## x dplyr::mutate()    masks plyr::mutate()
## x dplyr::rename()    masks plyr::rename()
## x dplyr::summarise() masks plyr::summarise()
## x dplyr::summarize() masks plyr::summarize()
library(formattable)# table
library(splitstackshape) # split columns
library(jsonlite) #JSON format 
## 
## Attaching package: 'jsonlite'
## The following object is masked from 'package:purrr':
## 
##     flatten
library(ggthemes) #Themes for plot
library(tm) # Sentiment Analysis 
## Loading required package: NLP
## 
## Attaching package: 'NLP'
## The following object is masked from 'package:ggplot2':
## 
##     annotate
library(stringr) #String Manipulation
movie <- read_csv("tmdb_5000_movies.csv",col_names=TRUE,na="NA")
## Parsed with column specification:
## cols(
##   .default = col_character(),
##   budget = col_double(),
##   id = col_double(),
##   popularity = col_double(),
##   release_date = col_date(format = ""),
##   revenue = col_double(),
##   runtime = col_double(),
##   vote_average = col_double(),
##   vote_count = col_double()
## )
## See spec(...) for full column specifications.
credit <- read_csv("tmdb_5000_credits.csv",col_names=TRUE,na="NA")
## Parsed with column specification:
## cols(
##   movie_id = col_double(),
##   title = col_character(),
##   cast = col_character(),
##   crew = col_character()
## )

2.1 Movies Dataset

glimpse(movie)
## Observations: 4,803
## Variables: 20
## $ budget               <dbl> 2.37e+08, 3.00e+08, 2.45e+08, 2.50e+08, 2...
## $ genres               <chr> "[{\"id\": 28, \"name\": \"Action\"}, {\"...
## $ homepage             <chr> "http://www.avatarmovie.com/", "http://di...
## $ id                   <dbl> 19995, 285, 206647, 49026, 49529, 559, 38...
## $ keywords             <chr> "[{\"id\": 1463, \"name\": \"culture clas...
## $ original_language    <chr> "en", "en", "en", "en", "en", "en", "en",...
## $ original_title       <chr> "Avatar", "Pirates of the Caribbean: At W...
## $ overview             <chr> "In the 22nd century, a paraplegic Marine...
## $ popularity           <dbl> 150.43758, 139.08262, 107.37679, 112.3129...
## $ production_companies <chr> "[{\"name\": \"Ingenious Film Partners\",...
## $ production_countries <chr> "[{\"iso_3166_1\": \"US\", \"name\": \"Un...
## $ release_date         <date> 2009-12-10, 2007-05-19, 2015-10-26, 2012...
## $ revenue              <dbl> 2787965087, 961000000, 880674609, 1084939...
## $ runtime              <dbl> 162, 169, 148, 165, 132, 139, 100, 141, 1...
## $ spoken_languages     <chr> "[{\"iso_639_1\": \"en\", \"name\": \"Eng...
## $ status               <chr> "Released", "Released", "Released", "Rele...
## $ tagline              <chr> "Enter the World of Pandora.", "At the en...
## $ title                <chr> "Avatar", "Pirates of the Caribbean: At W...
## $ vote_average         <dbl> 7.2, 6.9, 6.3, 7.6, 6.1, 5.9, 7.4, 7.3, 7...
## $ vote_count           <dbl> 11800, 4500, 4466, 9106, 2124, 3576, 3330...

2.2 Credits Dataset

glimpse(credit)
## Observations: 4,803
## Variables: 4
## $ movie_id <dbl> 19995, 285, 206647, 49026, 49529, 559, 38757, 99861, ...
## $ title    <chr> "Avatar", "Pirates of the Caribbean: At World's End",...
## $ cast     <chr> "[{\"cast_id\": 242, \"character\": \"Jake Sully\", \...
## $ crew     <chr> "[{\"credit_id\": \"52fe48009251416c750aca23\", \"dep...

2.3 Summary

summary(movie)
##      budget             genres            homepage        
##  Min.   :        0   Length:4803        Length:4803       
##  1st Qu.:   790000   Class :character   Class :character  
##  Median : 15000000   Mode  :character   Mode  :character  
##  Mean   : 29045040                                        
##  3rd Qu.: 40000000                                        
##  Max.   :380000000                                        
##                                                           
##        id           keywords         original_language  original_title    
##  Min.   :     5   Length:4803        Length:4803        Length:4803       
##  1st Qu.:  9014   Class :character   Class :character   Class :character  
##  Median : 14629   Mode  :character   Mode  :character   Mode  :character  
##  Mean   : 57166                                                           
##  3rd Qu.: 58611                                                           
##  Max.   :459488                                                           
##                                                                           
##    overview           popularity      production_companies
##  Length:4803        Min.   :  0.000   Length:4803         
##  Class :character   1st Qu.:  4.668   Class :character    
##  Mode  :character   Median : 12.922   Mode  :character    
##                     Mean   : 21.492                       
##                     3rd Qu.: 28.314                       
##                     Max.   :875.581                       
##                                                           
##  production_countries  release_date           revenue         
##  Length:4803          Min.   :1916-09-04   Min.   :0.000e+00  
##  Class :character     1st Qu.:1999-07-14   1st Qu.:0.000e+00  
##  Mode  :character     Median :2005-10-03   Median :1.917e+07  
##                       Mean   :2002-12-27   Mean   :8.226e+07  
##                       3rd Qu.:2011-02-16   3rd Qu.:9.292e+07  
##                       Max.   :2017-02-03   Max.   :2.788e+09  
##                       NA's   :1                               
##     runtime      spoken_languages      status            tagline         
##  Min.   :  0.0   Length:4803        Length:4803        Length:4803       
##  1st Qu.: 94.0   Class :character   Class :character   Class :character  
##  Median :103.0   Mode  :character   Mode  :character   Mode  :character  
##  Mean   :106.9                                                           
##  3rd Qu.:118.0                                                           
##  Max.   :338.0                                                           
##  NA's   :2                                                               
##     title            vote_average      vote_count     
##  Length:4803        Min.   : 0.000   Min.   :    0.0  
##  Class :character   1st Qu.: 5.600   1st Qu.:   54.0  
##  Mode  :character   Median : 6.200   Median :  235.0  
##                     Mean   : 6.092   Mean   :  690.2  
##                     3rd Qu.: 6.800   3rd Qu.:  737.0  
##                     Max.   :10.000   Max.   :13752.0  
## 

Dari ringkasan yang dataset movies, analisis yang dilakukan akan fokus pada deretan film yang memiliki budget dan revenue tertinggi, film dengan tingkat popularitas tertinggi dan lain-lain. Sedangkan pada dataset credits akan memvisualisasikan siapa artis yang paling banyak memiliki peran dalam dunia akting/film.

3 Data Cleaning

Sebelum melakukan analisis ada baiknya melakukan data cleansing terlebih dahulu.

3.1 Cleaning the Movie Dataset

Pada dataset ini terdapat variable data dengan format JSON. Maka kita extract datatersebut dengan menggunakan jsonlite library.

genredf = movie %>% filter(nchar(genres)>2) %>% 
  mutate(js=lapply(genres,fromJSON)) %>% unnest(js) %>% 
  select(id,title,genre=name) #Convert JSON format into data frame
slice(genredf)
## # A tibble: 12,160 x 3
##        id title                                    genre          
##     <dbl> <chr>                                    <chr>          
##  1  19995 Avatar                                   Action         
##  2  19995 Avatar                                   Adventure      
##  3  19995 Avatar                                   Fantasy        
##  4  19995 Avatar                                   Science Fiction
##  5    285 Pirates of the Caribbean: At World's End Adventure      
##  6    285 Pirates of the Caribbean: At World's End Fantasy        
##  7    285 Pirates of the Caribbean: At World's End Action         
##  8 206647 Spectre                                  Action         
##  9 206647 Spectre                                  Adventure      
## 10 206647 Spectre                                  Crime          
## # ... with 12,150 more rows

4 Data Visualization

4.1 Film dengan Biaya Produksi Termahal

movie %>% select(original_title,budget) %>% drop_na(original_title)%>% 
  arrange(desc(budget)) %>% head(20) %>%  
  ggplot(aes(reorder(original_title,budget),
  budget,fill=original_title))+
  geom_bar(stat="identity")+theme(axis.text.x = element_text(angle=90),
  plot.title=element_text(color="Black",face="bold"),
  legend.position="none")+scale_y_continuous(labels=scales::comma)+
  labs(x="",y="Total Anggaran dalam $",
       title="20 Film Dengan Biaya Produksi Termahal")

Dari grafik data visualisi diatas, terlihat bahwa seri Film Pirates of The Caribbean adalah deretan pertama dengan biaya produksi tertinggi dengan biaya produksi melebihi $300 juta USD, yang diikuti oleh Avengeres. Pada umumnya, banyak orang mengira film action superhero seperti Avenger merupakan film dengan biaya produksi termahal. Namun pada data diatas Avenger menduduki peringkat ketiga dengan biaya produksi termahal.

4.2 Film dengan Pendapatan Tertinggi

movie %>% select(original_title,revenue) %>% 
  drop_na(original_title)%>% arrange(desc(revenue)) %>% 
  head(20)  %>% ggplot(aes(reorder(original_title,revenue),
  revenue,fill=original_title))+geom_bar(stat="identity")+
  theme(axis.text.x = element_text(angle=90),
        plot.title=element_text(color="Black",face="bold"),
        legend.position="none")+scale_y_continuous(limits=c(0,3000000000),
        breaks=seq(0,3000000000,500000000),
        labels=scales::comma)+labs(x="",y="Total Revenue in $",
        title="Highest Grossing Movies -Top 20")

Visualisasi Grafik diatas menjelaskan bahwa Avatar memegang rekor film terlaris mengumpulkan sedikit lebih dari 2,6 miliar USD, berikutnya adalah film klasik Titanic. Bila dikaitkan dengan visualisasi 20 film dengan biaya produksi tertinggi, Avatar menduduki deretan/peringkat ke 18. Berbanding terbalik dengan Seri Film Pirates of Caribbean berdasarkan grafik pendapatan hanya mampu menduduki ke 17 dan 18. Sedangkan Avenger konsisten pada urutan ke 3 untuk posisi film dengan biaya produksi termahal dan pendapatan tertinggi.

6 Artis dengan Film Terbanyak

Saat visualisasi dataset credit. Siapa artis dengan film terbanyak?? Apakah Nicholas Saputra masuk dalam jajaran aktor dengan jumlah film terbanyak?? Mari kita lihat.

credit %>% group_by(name) %>% tally() %>% arrange(desc(n)) %>% head(20) %>% ggplot(aes(factor(name,levels=name),n,fill=name))+
  geom_bar(stat="identity")+
  labs(x="Artist",y="Count",title="20 Artis dengan Film Terbanyak")+
  theme_few()+
  theme(axis.text.x=element_text(angle=90),
        plot.title=element_text(hjust=0.5,color="red"),
        legend.position="none")

Ternyata tidak. Nicholas Saputra tidak masuk dalam jajaran aktor dengan jumlah film terbanyak. Dalam visualisasi diatas, Samuel.L.Jackson adalah aktor dengan film terbanyak yang berperan di lebih dari 60 film, diikuti oleh Robert De Niro dan Bruce Willis.