The IMDB dataset contains information about movies, including their names, release dates, user ratings, genres, overviews, cast and crew members, original titles, production status, original languages, budgets, revenues, and countries of origin. This data can be used for various analyses, such as identifying trends in movie genres, exploring the relationship between budget and revenue, and predicting the success of future movies.
# Load the lubridate package
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(plyr)
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following objects are masked from 'package:plyr':
##
## arrange, mutate, rename, summarise
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(readr)
movieData <-read.csv('C:/Users/govin/OneDrive/Desktop/RStudio/Data/imdb_movies.csv')
movieData$date_x <- sapply(movieData$date_x, function(x) gsub("/", "-", x))
movieData[c('date_x')] <- lapply(movieData[c('date_x')], function(x) as.Date(x, format="%m-%d-%Y"))
movieData <- type_convert(movieData)
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## names = col_character(),
## genre = col_character(),
## overview = col_character(),
## crew = col_character(),
## orig_title = col_character(),
## status = col_character(),
## orig_lang = col_character(),
## country = col_character()
## )
head(movieData, 10)
## names date_x score
## 1 Creed III 2023-03-02 73
## 2 Avatar: The Way of Water 2022-12-15 78
## 3 The Super Mario Bros. Movie 2023-04-05 76
## 4 Mummies 2023-01-05 70
## 5 Supercell 2023-03-17 61
## 6 Cocaine Bear 2023-02-23 66
## 7 John Wick: Chapter 4 2023-03-23 80
## 8 Puss in Boots: The Last Wish 2022-12-26 83
## 9 Attack on Titan 2022-09-30 59
## 10 The Park 2023-03-02 58
## genre
## 1 Drama, Action
## 2 Science Fiction, Adventure, Action
## 3 Animation, Adventure, Family, Fantasy, Comedy
## 4 Animation, Comedy, Family, Adventure, Fantasy
## 5 Action
## 6 Thriller, Comedy, Crime
## 7 Action, Thriller, Crime
## 8 Animation, Family, Fantasy, Adventure, Comedy
## 9 Action, Science Fiction
## 10 Action, Drama, Horror, Science Fiction, Thriller
## overview
## 1 After dominating the boxing world, Adonis Creed has been thriving in both his career and family life. When a childhood friend and former boxing prodigy, Damien Anderson, resurfaces after serving a long sentence in prison, he is eager to prove that he deserves his shot in the ring. The face-off between former friends is more than just a fight. To settle the score, Adonis must put his future on the line to battle Damien — a fighter who has nothing to lose.
## 2 Set more than a decade after the events of the first film, learn the story of the Sully family (Jake, Neytiri, and their kids), the trouble that follows them, the lengths they go to keep each other safe, the battles they fight to stay alive, and the tragedies they endure.
## 3 While working underground to fix a water main, Brooklyn plumbers—and brothers—Mario and Luigi are transported down a mysterious pipe and wander into a magical new world. But when the brothers are separated, Mario embarks on an epic quest to find Luigi.
## 4 Through a series of unfortunate events, three mummies end up in present-day London and embark on a wacky and hilarious journey in search of an old ring belonging to the Royal Family, stolen by ambitious archaeologist Lord Carnaby.
## 5 Good-hearted teenager William always lived in hope of following in his late father’s footsteps and becoming a storm chaser. His father’s legacy has now been turned into a storm-chasing tourist business, managed by the greedy and reckless Zane Rogers, who is now using William as the main attraction to lead a group of unsuspecting adventurers deep into the eye of the most dangerous supercell ever seen.
## 6 Inspired by a true story, an oddball group of cops, criminals, tourists and teens converge in a Georgia forest where a 500-pound black bear goes on a murderous rampage after unintentionally ingesting cocaine.
## 7 With the price on his head ever increasing, John Wick uncovers a path to defeating The High Table. But before he can earn his freedom, Wick must face off against a new enemy with powerful alliances across the globe and forces that turn old friends into foes.
## 8 Puss in Boots discovers that his passion for adventure has taken its toll: He has burned through eight of his nine lives, leaving him with only one life left. Puss sets out on an epic journey to find the mythical Last Wish and restore his nine lives.
## 9 As viable water is depleted on Earth, a mission is sent to Saturn's moon Titan to retrieve sustainable H2O reserves from its alien inhabitants. But just as the humans acquire the precious resource, they are attacked by Titan rebels, who don't trust that the Earthlings will leave in peace.
## 10 A dystopian coming-of-age movie focused on three kids who find themselves in an abandoned amusement park, aiming to unite whoever remains. With dangers lurking around every corner, they will do whatever it takes to survive their hellish Neverland.
## crew
## 1 Michael B. Jordan, Adonis Creed, Tessa Thompson, Bianca Taylor, Jonathan Majors, Damien Anderson, Wood Harris, Tony 'Little Duke' Evers, Phylicia Rashād, Mary Anne Creed, Mila Davis-Kent, Amara Creed, Florian Munteanu, Viktor Drago, José Benavidez Jr., Felix Chavez, Selenis Leyva, Laura Chavez
## 2 Sam Worthington, Jake Sully, Zoe Saldaña, Neytiri, Sigourney Weaver, Kiri / Dr. Grace Augustine, Stephen Lang, Colonel Miles Quaritch, Kate Winslet, Ronal, Cliff Curtis, Tonowari, Joel David Moore, Norm Spellman, CCH Pounder, Mo'at, Edie Falco, General Frances Ardmore
## 3 Chris Pratt, Mario (voice), Anya Taylor-Joy, Princess Peach (voice), Charlie Day, Luigi (voice), Jack Black, Bowser (voice), Keegan-Michael Key, Toad (voice), Seth Rogen, Donkey Kong (voice), Fred Armisen, Cranky Kong (voice), Kevin Michael Richardson, Kamek (voice), Sebastian Maniscalco, Spike (voice)
## 4 Óscar Barberán, Thut (voice), Ana Esther Alborg, Nefer (voice), Luis Pérez Reina, Carnaby (voice), María Luisa Solá, Madre (voice), Jaume Solà, Sekhem (voice), José Luis Mediavilla, Ed (voice), José Javier Serrano Rodríguez, Danny (voice), Aleix Estadella, Dennis (voice), María Moscardó, Usi (voice)
## 5 Skeet Ulrich, Roy Cameron, Anne Heche, Dr Quinn Brody, Daniel Diemer, William Brody, Jordan Kristine Seamón, Harper Hunter, Alec Baldwin, Zane Rogers, Richard Gunn, Bill Brody, Praya Lundberg, Amy, Johnny Wactor, Martin, Anjul Nigam, Ramesh
## 6 Keri Russell, Sari, Alden Ehrenreich, Eddie, O'Shea Jackson Jr., Daveed, Ray Liotta, Syd, Kristofer Hivju, Olaf (Kristoffer), Margo Martindale, Ranger Liz, Christian Convery, Henry, Isiah Whitlock Jr., Bob, Jesse Tyler Ferguson, Peter
## 7 Keanu Reeves, John Wick, Donnie Yen, Caine, Bill Skarsgård, Marquis de Gramont, Ian McShane, Winston, Laurence Fishburne, Bowery King, Lance Reddick, Charon, Clancy Brown, The Harbinger, Hiroyuki Sanada, Shimazu, Shamier Anderson, Mr Nobody
## 8 Antonio Banderas, Puss in Boots (voice), Salma Hayek, Kitty Softpaws (voice), Harvey Guillén, Perrito (voice), Wagner Moura, Wolf (voice), Florence Pugh, Goldilocks (voice), Olivia Colman, Mama Bear (voice), Ray Winstone, Papa Bear (voice), Samson Kayo, Baby Bear (voice), John Mulaney, Jack Horner (voice)
## 9 Paul Bianchi, Computer (voice), Erin Coker, Allison Quince, Jack Pearson, Max Reece, Anthony Jensen, Jowers, Neli Sabour, Heidi Quince, Karan Sagoo, Adrian Naidu, Natalie Storrs, Saoirse Parker, Justin Tanks, Mark Morales, Jenny Tran, Kim Costa
## 10 Chloe Guidry, Ines, Nhedrick Jabier, Bui, Carmina Garay, Kuan, Billy Slaughter, Martin Parker, Carli McIntyre, Rue, Laura Coover, Reporter, Presley Richardson, Bennett, Sean Papajohn, Jack, Legend Jay Jones, Slingshot Gang
## orig_title status orig_lang budget_x
## 1 Creed III Released English 75000000
## 2 Avatar: The Way of Water Released English 460000000
## 3 The Super Mario Bros. Movie Released English 100000000
## 4 Momias Released Spanish, Castilian 12300000
## 5 Supercell Released English 77000000
## 6 Cocaine Bear Released English 35000000
## 7 John Wick: Chapter 4 Released English 100000000
## 8 Puss in Boots: The Last Wish Released English 90000000
## 9 Attack on Titan Released English 71000000
## 10 The Park Released English 119200000
## revenue country
## 1 271616668 AU
## 2 2316794914 AU
## 3 724459031 AU
## 4 34200000 AU
## 5 340941959 US
## 6 80000000 AU
## 7 351349364 AU
## 8 483480577 AU
## 9 254946484 US
## 10 488962491 US
summary(movieData)
## names date_x score genre
## Length:10178 Min. :1903-05-15 Min. : 0.0 Length:10178
## Class :character 1st Qu.:2001-12-25 1st Qu.: 59.0 Class :character
## Mode :character Median :2013-05-09 Median : 65.0 Mode :character
## Mean :2008-06-15 Mean : 63.5
## 3rd Qu.:2019-10-17 3rd Qu.: 71.0
## Max. :2023-12-31 Max. :100.0
## overview crew orig_title status
## Length:10178 Length:10178 Length:10178 Length:10178
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
## orig_lang budget_x revenue country
## Length:10178 Min. : 1 Min. :0.000e+00 Length:10178
## Class :character 1st Qu.: 15000000 1st Qu.:2.859e+07 Class :character
## Mode :character Median : 50000000 Median :1.529e+08 Mode :character
## Mean : 64882379 Mean :2.531e+08
## 3rd Qu.:105000000 3rd Qu.:4.178e+08
## Max. :460000000 Max. :2.924e+09
numeric_data <- unlist(lapply(movieData, is.numeric))
data_num <- movieData[ , numeric_data] #Subsetting numeric columns of data
summary(data_num)
## score budget_x revenue
## Min. : 0.0 Min. : 1 Min. :0.000e+00
## 1st Qu.: 59.0 1st Qu.: 15000000 1st Qu.:2.859e+07
## Median : 65.0 Median : 50000000 Median :1.529e+08
## Mean : 63.5 Mean : 64882379 Mean :2.531e+08
## 3rd Qu.: 71.0 3rd Qu.:105000000 3rd Qu.:4.178e+08
## Max. :100.0 Max. :460000000 Max. :2.924e+09
count(movieData, 'country')
## "country" n
## 1 country 10178
library(plyr)
count(movieData, 'orig_lang')
## "orig_lang" n
## 1 orig_lang 10178
status
count(movieData, 'status')
## "status" n
## 1 status 10178
Revenue_country_wise <- aggregate(movieData$revenue, list(movieData$country), FUN=mean)
Revenue_country_wise <- Revenue_country_wise[order(Revenue_country_wise$x, decreasing = TRUE), ]
print(Revenue_country_wise)
## Group.1 x
## 36 MU 728608266
## 22 GT 655664752
## 5 BO 638332463
## 44 PR 545316308
## 35 LV 542233172
## 12 CO 534571540
## 37 MX 469644985
## 1 AR 456560785
## 54 TW 451275064
## 30 IS 443980387
## 43 PL 440802594
## 32 JP 408106272
## 16 DO 400066522
## 52 TH 381085420
## 10 CL 376139634
## 24 HU 370750873
## 39 NL 369452979
## 6 BR 367192509
## 41 PE 361959154
## 14 DE 358353693
## 31 IT 357659815
## 46 PY 356935817
## 34 KR 350030132
## 17 ES 345563529
## 53 TR 337170686
## 49 SG 333077714
## 42 PH 331340101
## 23 HK 330804782
## 4 BE 328309975
## 13 CZ 316265039
## 25 ID 313651704
## 48 SE 312184372
## 19 FR 305631854
## 9 CH 297093649
## 11 CN 296076152
## 20 GB 295877850
## 28 IN 285128163
## 26 IE 270712673
## 56 US 270571053
## 27 IL 254504167
## 8 CA 253273459
## 15 DK 239348748
## 47 RU 220233805
## 40 NO 209286725
## 60 ZA 208272848
## 58 VN 206250037
## 29 IR 193600405
## 3 AU 192945447
## 57 UY 179105223
## 51 SU 177365780
## 7 BY 175269999
## 33 KH 175269999
## 50 SK 175269999
## 21 GR 154849503
## 55 UA 127479530
## 2 AT 72282768
## 18 FI 66214266
## 59 XC 23146523
## 38 MY 22443973
## 45 PT 1240262
MU has highest avg revenue
aggregate(movieData$status, by = list(movieData$status, movieData$status), FUN = length)
## Group.1 Group.2 x
## 1 In Production In Production 16
## 2 Post Production Post Production 31
## 3 Released Released 10131
Movies count categorized
movieData$decade <- year(movieData$date_x)%/%10 * 10
ggplot(movieData, aes(x = decade, y = budget_x)) +
geom_point() +
geom_jitter() +
geom_smooth()
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
Movie budgets have been gradually increasing over the years.By regression we can expect this trend to continue.
options(repr.plot.width = 10, repr.plot.height = 10)
ggplot(movieData, aes(x = budget_x, y = revenue, color = decade)) +
geom_point() +
geom_jitter() +
geom_smooth()
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## Warning: The following aesthetics were dropped during statistical transformation: colour
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
## the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
## variable into a factor?
options(repr.plot.width = 20, repr.plot.height = 30)
ggplot(movieData, aes(x = budget_x, y = country, color = decade)) +
geom_point() +
geom_jitter() +
geom_smooth()
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## Warning: Computation failed in `stat_smooth()`
## Caused by error in `gam.reparam()`:
## ! NA/NaN/Inf in foreign function call (arg 3)
## Relation between movies and their country
There is direct positive correlation between budget and revenue.
options(repr.plot.width = 10, repr.plot.height = 10)
ggplot(filter(movieData, orig_lang == "Korean" | orig_lang == "English"), aes(x = budget_x, y = revenue, color = orig_lang)) +
geom_point() +
geom_jitter() +
geom_smooth()
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
options(repr.plot.width = 16, repr.plot.height = 16)
movieData$year <- year(movieData$date_x)
ggplot(filter(movieData, orig_lang == "Korean"), aes(x = year)) +
geom_bar()
Korean movies seem to be gaining in popularity
options(repr.plot.width = 16, repr.plot.height = 16)
ggplot(movieData, aes(x = score, y = revenue, color = decade)) +
geom_point() +
geom_jitter()
There is good correlation between the movie’s IMDB rating and its collection at box office. It seems after a threshold, there is no direct correlation.
# Creating a histogram
hist(movieData$revenue,
main = "Distribution of Revenue",
xlab = "Revenue", # X-axis label
ylab = "Frequency", # Y-axis label
col = "green", # Bar color
border = "black", # Border color
breaks = 20,
freq = FALSE) # Number of bins or breaks
# Displaying density also
lines(density(movieData$revenue), col = "black", lwd = 2)
# Creating a histogram
hist(movieData$budget,
main = "Distribution of Budget",
xlab = "Revenue", # X-axis label
ylab = "Frequency", # Y-axis label
col = "orange", # Bar color
border = "black", # Border color
breaks = 20,
freq = FALSE) # Number of bins or breaks
# Displaying density also
lines(density(movieData$revenue), col = "black", lwd = 2)
# Creating a histogram
hist(movieData$score,
main = "Distribution of Score",
xlab = "Revenue", # X-axis label
ylab = "Frequency", # Y-axis label
col = "violet", # Bar color
border = "black", # Border color
breaks = 20,
freq = FALSE) # Number of bins or breaks
# Displaying density also
lines(density(movieData$revenue), col = "black", lwd = 2)
pie(table(movieData$country),
main = "Category- Countries",
xlab = "Categories",
ylab = "Frequency")
pie(table(movieData$orig_lang),
main = "Category- Language",
xlab = "Categories",
ylab = "Frequency")
pie(table(movieData$status),
main = "Category- Status",
xlab = "Categories",
ylab = "Frequency")
library(ggplot2)
library(reshape2)
movieData_corr <- cor(data_num)
heatmap_plot <- ggplot(data = melt(movieData_corr), aes(x = Var1, y = Var2, fill = value)) +
geom_tile() +
geom_text(aes(label = round(value, 2)), vjust = 1) +
labs(title = "Correlation Heatmap for continuous variables", x = "Features", y = "Features", fill = "Correlation")
# Print the heatmap
print(heatmap_plot)
plot(movieData$budget, movieData$revenue,
main = "Scatter Plot: Budget vs. Revenue",
xlab = "Budget",
ylab = "Revenue",
col = "green"
)
Good correlation between Budget and Revenue