m.names <- c("Baramgwa hamjje sarajida", "Sleepless in Seattle", "The Water Diviner", 
"Fly Away Home", "The Three Musketeers", "Candyman: Farewell to Flesh", 
"Honey I Blew Up the Kid", "Kingsman: The Secret Service", "Ajab Prem Ki Ghazab Kahani", 
"A Bug's Life", "Courage Under Fire", "Dirty Pretty Things", 
"In the Name of the Father", "Soul Plane", "Magnum Force", "About Time", 
"House of Sand and Fog", "Bokura ga ita Zenpen", "Jackass 3D", 
"Tropic Thunder - A Pirate's Tale")

boxoffice <- c(28686545, 218076024, 30864649, 35870837, 50375628, 13899536, 
58662452, 404561724, 15906411, 363089431, 100748262, 14156753, 
25096862, 14553807, 44680473, 89177486, 16157923, 26324268, 171685793, 
191091250)

genre <- c("Action", "Romantic Comedy", "Drama", "Drama", "Adventure", 
"Horror", "Comedy", "Action", "Comedy", "Adventure", "Drama", 
"Drama", "Drama", "Comedy", "Action", "Romantic Comedy", "Drama", 
"Drama", "Comedy", "Comedy")

time <- c(121, 100, 112, NA, NA, NA, NA, 129, NA, 96, 111, NA, NA, NA, 
NA, 123, NA, 121, 93, 106)

rating <- c(NA, "PG", "R", "PG", "PG", "R", "PG", "R", NA, "G", "R", 
"R", "R", "R", NA, "R", "R", NA, "R", "R")

Q1

Here are the vectors from last week’s WPA.Using these vectors, create a dataframe called (short for movies.sample) that contain the vectors.

ms <- data.frame(m.names, boxoffice, genre, time, rating)

For the rest of the WPA, we’ll use the entire movies dataset.

# install packages
#install.packages("devtools")
library("devtools")
## Warning: package 'devtools' was built under R version 3.1.3
#install_github("ndphillips/yarrr")
library("yarrr")
## Loading required package: jpeg
## Loading required package: 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

Q2

How many rows and columns are in the movies dataset?

m <- movies
ncol(m)
## [1] 17

What are the column names?

ncol(m)
## [1] 17

Q3

Look at the first few rows of the dataset using the head() function.

head(m)
##                          name boxoffice.total boxoffice.domestic
## 1                      Avatar      2783918982          760507625
## 2                     Titanic      2207615668          658672302
## 3              Jurassic World      1665443635          651443635
## 4                The Avengers      1519479547          623279547
## 5                   Furious 7      1516246709          351032910
## 6 The Avengers: Age of Ultron      1404705868          459005868
##   boxoffice.international dvd.domestic    budget rating             genre
## 1              2023411357    230915507 425000000  PG-13            Action
## 2              1548943366           NA 200000000  PG-13 Thriller/Suspense
## 3              1014000000           NA 215000000  PG-13            Action
## 4               896200000    109515497 225000000  PG-13         Adventure
## 5              1165213799     14947559 190000000  PG-13            Action
## 6               945700000      7312791 250000000  PG-13            Action
##          creative.type time year     production.method sequel
## 1      Science Fiction  162 2009 Animation/Live Action      0
## 2   Historical Fiction  194 1997           Live Action      0
## 3      Science Fiction  124 2015           Live Action      1
## 4           Super Hero  143 2012 Animation/Live Action      0
## 5 Contemporary Fiction  137 2014           Live Action      1
## 6           Super Hero  141 2015           Live Action      1
##   boxoffice.domestic.inflationadj budget.millions boxoffice.total.millions
## 1                       826198130             425                 2783.919
## 2                      1139182838             200                 2207.616
## 3                       651443635             215                 1665.444
## 4                       655383136             225                 1519.480
## 5                       351032910             190                 1516.247
## 6                       459005868             250                 1404.706
##   revenue.d.budget
## 1         6.550398
## 2        11.038078
## 3         7.746249
## 4         6.753242
## 5         7.980246
## 6         5.618823

Look at the last few rows using the tail() function.

tail(m)
##                               name boxoffice.total boxoffice.domestic
## 4995                      Idlewild        12571185           12571185
## 4996 Hellraiser III: Hell on Earth        12525537           12525537
## 4997                 Sorority Boys        12516222           10198766
## 4998                    Love Jones        12514138           12514138
## 4999                         Klute        12512637           12512637
## 5000        Breakin' All the Rules        12512317           12232382
##      boxoffice.international dvd.domestic   budget rating           genre
## 4995                       0      8753109 15000000      R         Musical
## 4996                       0           NA        0      R          Horror
## 4997                 2317456           NA 12000000      R          Comedy
## 4998                       0           NA 10000000      R           Drama
## 4999                       0           NA        0   <NA>            <NA>
## 5000                  279935           NA  9000000  PG-13 Romantic Comedy
##             creative.type time year production.method sequel
## 4995   Historical Fiction   NA 2006       Live Action      0
## 4996              Fantasy   NA 1992       Live Action      1
## 4997 Contemporary Fiction   NA 2002       Live Action      0
## 4998 Contemporary Fiction   NA 1997       Live Action      0
## 4999                 <NA>   NA 1971              <NA>      0
## 5000 Contemporary Fiction   NA 2004       Live Action      0
##      boxoffice.domestic.inflationadj budget.millions
## 4995                        16064248              15
## 4996                        12525537               0
## 4997                        14692539              12
## 4998                        22819901              10
## 4999                        63473192               0
## 5000                        16487126               9
##      boxoffice.total.millions revenue.d.budget
## 4995                 12.57118         0.838079
## 4996                 12.52554              Inf
## 4997                 12.51622         1.043019
## 4998                 12.51414         1.251414
## 4999                 12.51264              Inf
## 5000                 12.51232         1.390257

Look at rows 20 through 30.

m[20:30,]
##                                            name boxoffice.total
## 20          Star Wars Ep. I: The Phantom Menace      1027044677
## 21                          Alice in Wonderland      1025491110
## 22            The Hobbit: An Unexpected Journey      1017003568
## 23                              The Dark Knight      1002891358
## 24                                The Lion King       987480140
## 25                              Despicable Me 2       974873764
## 26     Harry Potter and the Sorcerer\xd5s Stone       974755371
## 27     Pirates of the Caribbean: At World's End       963420425
## 28          The Hobbit: The Desolation of Smaug       960366855
## 29 Harry Potter and the Deathly Hallows: Part I       959301070
## 30    The Hobbit: The Battle of the Five Armies       955119788
##    boxoffice.domestic boxoffice.international dvd.domestic    budget
## 20          474544677               552500000           NA 115000000
## 21          334191110               691300000     82297116 200000000
## 22          303003568               714000000     34191124 250000000
## 23          533345358               469546000    282134660 185000000
## 24          422780140               564700000     86246006  79300000
## 25          368065385               606808379    124381409  76000000
## 26          317575550               657179821           NA 125000000
## 27          309420425               654000000    312228146 300000000
## 28          258366855               702000000     40247146 250000000
## 29          295001070               664300000     94385569 125000000
## 30          255119788               700000000     22439417 250000000
##    rating     genre      creative.type time year     production.method
## 20     PG Adventure    Science Fiction  133 1999 Animation/Live Action
## 21     PG Adventure            Fantasy  108 2010 Animation/Live Action
## 22  PG-13 Adventure            Fantasy  169 2012 Animation/Live Action
## 23  PG-13    Action         Super Hero  152 2008           Live Action
## 24      G Adventure       Kids Fiction   87 1994        Hand Animation
## 25     PG    Comedy       Kids Fiction   98 2013     Digital Animation
## 26     PG Adventure            Fantasy  152 2001 Animation/Live Action
## 27  PG-13 Adventure Historical Fiction  167 2007           Live Action
## 28  PG-13 Adventure            Fantasy  201 2013 Animation/Live Action
## 29  PG-13 Adventure            Fantasy  146 2010 Animation/Live Action
## 30  PG-13 Adventure            Fantasy  144 2014           Live Action
##    sequel boxoffice.domestic.inflationadj budget.millions
## 20      1                       755899504           115.0
## 21      0                       354522122           200.0
## 22      1                       317749322           250.0
## 23      1                       621624466           185.0
## 24      0                       756219975            79.3
## 25      1                       378930222            76.0
## 26      0                       468612897           125.0
## 27      1                       376431535           300.0
## 28      1                       265846191           250.0
## 29      1                       312886528           125.0
## 30      1                       260520067           250.0
##    boxoffice.total.millions revenue.d.budget
## 20                1027.0447         8.930823
## 21                1025.4911         5.127456
## 22                1017.0036         4.068014
## 23                1002.8914         5.421034
## 24                 987.4801        12.452461
## 25                 974.8738        12.827286
## 26                 974.7554         7.798043
## 27                 963.4204         3.211401
## 28                 960.3669         3.841467
## 29                 959.3011         7.674409
## 30                 955.1198         3.820479

Q4

Show me all the data for Harry Potter and the Chamber of Secrets

m[m$name == "Harry Potter and the Chamber of Secrets",]
##                                       name boxoffice.total
## 40 Harry Potter and the Chamber of Secrets       878979634
##    boxoffice.domestic boxoffice.international dvd.domestic    budget
## 40          261987880               616991754           NA 100000000
##    rating     genre creative.type time year     production.method sequel
## 40     PG Adventure       Fantasy  161 2002 Animation/Live Action      1
##    boxoffice.domestic.inflationadj budget.millions
## 40                       376584346             100
##    boxoffice.total.millions revenue.d.budget
## 40                 878.9796         8.789796

What was the rating of Harry Potter and the Chamber of Secrets? (use indexing!)

m$rating[m$name == "Harry Potter and the Chamber of Secrets"]
## [1] "PG"

What was the boxoffice total of Harry Potter and the Deathly Hallows?

m$boxoffice.total[m$name == "Harry Potter and the Deathly Hallows: Part I"]
## [1] 959301070

What was the running time of Harry Potter and the Order of the Phoenix?

m$time[m$name == "Harry Potter and the Order of the Phoenix"]
## [1] 138

Q5

It’s easy to sort rows in a dataframe according to a column: just use the following code structure

Using this logic, sort the movies dataframe by year (with the oldest movies at the top of the dataframe).

# Determine the order of rows according to the column you want
#  If you want to reverse the order, just change the decreasing argument to F.
index <- order(m$year, decreasing = F)

# Change the order of the dataframe based on the index
m <- m[index,]

What are the names of the 5 oldest movies in the dataset?

m$name[1:5]
## [1] "The Big Parade"                  "Snow White and the Seven Dwarfs"
## [3] "Gone with the Wind"              "The Wizard of Oz"               
## [5] "Pinocchio"

Q6

Now, sort the dataframe back into its original order (by boxoffice). The first movie in the dataframe should be Avatar!

index <- order(m$boxoffice.total, decreasing = T)
m <- m[index,]
m$name[1]
## [1] "Avatar"

Q7

Add a new column called “boxoffice.millions” that has the box-office values in millions of dollars. For example, a value of 1000000 in the original boxoffice vector should be 1 in boxoffice.millions

m$boxoffice.millions <- m$boxoffice.total / 1000000
names(m)
##  [1] "name"                            "boxoffice.total"                
##  [3] "boxoffice.domestic"              "boxoffice.international"        
##  [5] "dvd.domestic"                    "budget"                         
##  [7] "rating"                          "genre"                          
##  [9] "creative.type"                   "time"                           
## [11] "year"                            "production.method"              
## [13] "sequel"                          "boxoffice.domestic.inflationadj"
## [15] "budget.millions"                 "boxoffice.total.millions"       
## [17] "revenue.d.budget"                "boxoffice.millions"

Q8

What is the mean box-office totals of all movies?

mean(m$boxoffice.total)
## [1] 98205350

What is the median running length of the movies?

median(m$time, na.rm = T)
## [1] 108

What percent of the movies were sequels? (Hint: Use mean())

mean(m$sequel == 1, na.rm = T)
## [1] 0.1170213

Q9

What are the genres of the first 5 movies in the list?

m$genre[1:5]
## [1] "Action"            "Thriller/Suspense" "Action"           
## [4] "Adventure"         "Action"

What were the running times of those movies?

m$time[1:5]
## [1] 162 194 124 143 137

Q10

What were the names of all the different movie genres in the dataset?

unique(m$genre)
##  [1] "Action"              "Thriller/Suspense"   "Adventure"          
##  [4] "Comedy"              "Drama"               "Musical"            
##  [7] "Horror"              "Romantic Comedy"     "Western"            
## [10] "Black Comedy"        "Documentary"         NA                   
## [13] "Reality"             "Concert/Performance" "Multiple Genres"

How many movies were there of each genre?

table(m$genre)
## 
##              Action           Adventure        Black Comedy 
##                 692                 486                  34 
##              Comedy Concert/Performance         Documentary 
##                1212                  14                  63 
##               Drama              Horror     Multiple Genres 
##                1085                 300                   2 
##             Musical             Reality     Romantic Comedy 
##                  77                   2                 249 
##   Thriller/Suspense             Western 
##                 428                  38

Q11

Create a new dataframe called movies.comedy which only contains the data for comedy movies.

movies.comedy <- m[m$genre == "Comedy",]
mc <- movies.comedy

What was the mean budget of these movies?

mean(mc$budget, na.rm = T)
## [1] 19727314

What was the median boxoffice total of these movies?

median(mc$boxoffice.total, na.rm = T)
## [1] 40833410

Q12

What percent of the movies had either an R or a PG-13 rating? (hint: use %in%)

mean(m$rating %in% c("R","PG-13"))
## [1] 0.572

What was the mean boxoffice revenue (use your new boxoffice.millions column) of those movies?

mean(subset(m, m$rating =="R" | m$rating =="PG-13")$boxoffice.millions)
## [1] 112.6393

Q13

What were the names of the movies that were made before 1950?

subset(m, m$year < 1950)$name
##  [1] "Gone with the Wind"              "Bambi"                          
##  [3] "Snow White and the Seven Dwarfs" "Pinocchio"                      
##  [5] "Fantasia"                        "Song of the South"              
##  [7] "The Wizard of Oz"                "Samson and Delilah"             
##  [9] "Notorious"                       "The Best Years of Our Lives"    
## [11] "The Big Parade"                  "The Bells of St. Mary's"        
## [13] "Duel in the Sun"                 "This is the Army"               
## [15] "The Jolson Story"                "For Whom the Bell Tolls"        
## [17] "Sergeant York"                   "Going My Way"                   
## [19] "Mom and Dad"                     "Forever Amber"                  
## [21] "Welcome Stranger"                "Blue Skies"                     
## [23] "Leave Her to Heaven"             "Mrs. Miniver"                   
## [25] "Meet Me in St. Louis"

What was the mean running time of those movies in minutes?

mean(subset(m, m$year < 1950)$time, na.rm = T)
## [1] 95.83333

Q14

What percent of movies were Dramas?

mean(m$genre == "Drama",na.rm = T)
## [1] 0.2317386

What percent of the movies were over 100 minutes long?

mean(m$time > 100, na.rm = T)
## [1] 0.6591793

Q15

Create a new column called revenue.d.budget which shows a movie’s boxoffice total divided by its budget.

m$revenue.d.budget <- m$boxoffice.total / m$budget

Create a new dataframe called that only contains movies for which the budget was greater than 0.

ndf <- subset(m, m$budget > 0)

Which movie had the highest box office total relative to its budget?

ndf$name[ndf$revenue.d.budget == max(ndf$revenue.d.budget)]
## [1] "The Blair Witch Project"

Which comedy movie had the highest box office total relative to its budget?

ndf$name[max(ndf$revenue.d.budget[ndf$genre == "Comedy"], na.rm = T)]
## [1] "The Smurfs"

Q16

How many movies made less than $30 Million dollars AND were Comedies? (hint: Use subset() and nrow())

nrow(subset(m, m$boxoffice.millions < 30 & m$genre == "Comedy"))
## [1] 448

What were the names of these movies?

subset(m, m$boxoffice.millions < 30 & m$genre == "Comedy")$name
##   [1] "Neighbors"                                                               
##   [2] "7 Zwerge - Der Wald Ist Nicht Genug"                                     
##   [3] "St. Trinian's"                                                           
##   [4] "Madeline"                                                                
##   [5] "Small Time Crooks"                                                       
##   [6] "Blank Check"                                                             
##   [7] "Nothing in Common"                                                       
##   [8] "Major Payne"                                                             
##   [9] "Easy Money"                                                              
##  [10] "Romy and Michele's High School Reunion"                                  
##  [11] "Bulworth"                                                                
##  [12] "The New Guy"                                                             
##  [13] "Mr. Magoo"                                                               
##  [14] "In the Army Now"                                                         
##  [15] "Agent Cody Banks 2: Destination London"                                  
##  [16] "The Out-of-Towners"                                                      
##  [17] "L.A. Story"                                                              
##  [18] "\"Cop and &frac12;\""                                                    
##  [19] "The Cheap Detective"                                                     
##  [20] "Ernest Saves Christmas"                                                  
##  [21] "Police Academy 4: Citizens on Patrol"                                    
##  [22] "Out to Sea"                                                              
##  [23] "The Brothers"                                                            
##  [24] "Friday"                                                                  
##  [25] "Mrs. Henderson Presents"                                                 
##  [26] "Saving Grace"                                                            
##  [27] "Air Bud"                                                                 
##  [28] "Ramona and Beezus"                                                       
##  [29] "Samiy Luchshiy Film"                                                     
##  [30] "Desperately Seeking Susan"                                               
##  [31] "Clerks II"                                                               
##  [32] "Cannonball Run II"                                                       
##  [33] "The Muppet Christmas Carol"                                              
##  [34] "Welcome"                                                                 
##  [35] "Cadillac Man"                                                            
##  [36] "Baby Geniuses"                                                           
##  [37] "Observe and Report"                                                      
##  [38] "Fast Times at Ridgemont High"                                            
##  [39] "Monsoon Wedding"                                                         
##  [40] "Paulie"                                                                  
##  [41] "Relatos salvages"                                                        
##  [42] "Hors de Prix"                                                            
##  [43] "Spy Hard"                                                                
##  [44] "The Way Way Back"                                                        
##  [45] "Housefull 2"                                                             
##  [46] "The Dream Team"                                                          
##  [47] "A Prairie Home Companion"                                                
##  [48] "Bride Wars"                                                              
##  [49] "Blast from the Past"                                                     
##  [50] "First Kid"                                                               
##  [51] "Soul Man"                                                                
##  [52] "House Party"                                                             
##  [53] "The Whole Ten Yards"                                                     
##  [54] "Houseguest"                                                              
##  [55] "Wildcats"                                                                
##  [56] "Necessary Roughness"                                                     
##  [57] "Dumb and Dumberer: When Harry Met Lloyd"                                 
##  [58] "Protocol"                                                                
##  [59] "Couloirs du temps: Les visiteurs 2, Les"                                 
##  [60] "Your Highness"                                                           
##  [61] "Micki + Maude"                                                           
##  [62] "Torrente 4 (3D)"                                                         
##  [63] "Son in Law"                                                              
##  [64] "Mighty Aphrodite"                                                        
##  [65] "Freaky Friday"                                                           
##  [66] "Cactus Flower"                                                           
##  [67] "All About the Benjamins"                                                 
##  [68] "Saving Silverman"                                                        
##  [69] "Our Idiot Brother"                                                       
##  [70] "Bratz"                                                                   
##  [71] "Ice Princess"                                                            
##  [72] "Loaded Weapon 1"                                                         
##  [73] "Kokowaah 2"                                                              
##  [74] "Down Periscope"                                                          
##  [75] "Jumpin' Jack Flash"                                                      
##  [76] "Funny Farm"                                                              
##  [77] "The Muppets Take Manhattan"                                              
##  [78] "Top Five"                                                                
##  [79] "My Father the Hero"                                                      
##  [80] "Billy Madison"                                                           
##  [81] "Tin Men"                                                                 
##  [82] "The Absent Minded Professor"                                             
##  [83] "Can't Hardly Wait"                                                       
##  [84] "The Great Race"                                                          
##  [85] "Heartburn"                                                               
##  [86] "The Woman in Red"                                                        
##  [87] "Baby Boom"                                                               
##  [88] "Don't Tell Mom the Babysitter's Dead"                                    
##  [89] "Corky Romano"                                                            
##  [90] "Problem Child 2"                                                         
##  [91] "The Wood"                                                                
##  [92] "Mad Money"                                                               
##  [93] "Ernest Goes to Jail"                                                     
##  [94] "A Midsummer Night's Dream"                                               
##  [95] "Catch-22"                                                                
##  [96] "Recep Ivedik"                                                            
##  [97] "Airplane II: The Sequel"                                                 
##  [98] "Tees Maar Khan"                                                          
##  [99] "De l'autre c\x99t\x8e du p\x8eriph"                                      
## [100] "Lottery Ticket"                                                          
## [101] "Punch-Drunk Love"                                                        
## [102] "Joe Somebody"                                                            
## [103] "schlussmacher"                                                           
## [104] "I Don't Know How She Does It"                                            
## [105] "The In-Laws"                                                             
## [106] "Moscow on the Hudson"                                                    
## [107] "Do the Right Thing"                                                      
## [108] "The Incredible Burt Wonderstone"                                         
## [109] "Wanderlust"                                                              
## [110] "The Guru"                                                                
## [111] "Spring Break"                                                            
## [112] "The Flamingo Kid"                                                        
## [113] "Renaissance Man"                                                         
## [114] "Dickie Roberts: Former Child Star"                                       
## [115] "Good Burger"                                                             
## [116] "Sixteen Candles"                                                         
## [117] "Two of a Kind"                                                           
## [118] "My Blue Heaven"                                                          
## [119] "Oscar"                                                                   
## [120] "Ernest Goes to Camp"                                                     
## [121] "Summer Rental"                                                           
## [122] "Kingdom Come"                                                            
## [123] "Zambezia"                                                                
## [124] "Auntie Mame"                                                             
## [125] "Les femmes du 6\x8fme \x8etage"                                          
## [126] "Kuai Le Dao Jia"                                                         
## [127] "Super Troopers"                                                          
## [128] "I Love You, Phillip Morris"                                              
## [129] "Ghost Dad"                                                               
## [130] "Aquamarine"                                                              
## [131] "D3: The Mighty Ducks"                                                    
## [132] "Ella Enchanted"                                                          
## [133] "Crimes of the Heart"                                                     
## [134] "Modern Problems"                                                         
## [135] "Enough Said"                                                             
## [136] "Paris"                                                                   
## [137] "Raising Arizona"                                                         
## [138] "Young Adult"                                                             
## [139] "Pure Luck"                                                               
## [140] "Drive Me Crazy"                                                          
## [141] "Much Ado About Nothing"                                                  
## [142] "My Tutor"                                                                
## [143] "Captain Ron"                                                             
## [144] "Adaptation"                                                              
## [145] "My Bodyguard"                                                            
## [146] "Disco"                                                                   
## [147] "License to Drive"                                                        
## [148] "My Fellow Americans"                                                     
## [149] "The Last Starfighter"                                                    
## [150] "The Medallion"                                                           
## [151] "Home for the Holidays"                                                   
## [152] "Nosotros Los Nobles"                                                     
## [153] "Unaccompanied Minors"                                                    
## [154] "Reno 911!: Miami"                                                        
## [155] "Only the Lonely"                                                         
## [156] "Mr. 3000"                                                                
## [157] "Leap of Faith"                                                           
## [158] "Class"                                                                   
## [159] "The Rookie"                                                              
## [160] "Over Her Dead Body"                                                      
## [161] "Blackbeard's Ghost"                                                      
## [162] "Man of the House"                                                        
## [163] "Married to the Mob"                                                      
## [164] "Tough Guys"                                                              
## [165] "Toys"                                                                    
## [166] "Our Family Wedding"                                                      
## [167] "A Very Brady Sequel"                                                     
## [168] "Rhinestone"                                                              
## [169] "The Freshman"                                                            
## [170] "Revenge of the Nerds II: Nerds in Paradise"                              
## [171] "Happy-Go-Lucky"                                                          
## [172] "New York Minute"                                                         
## [173] "A Haunted House 2"                                                       
## [174] "Straight Talk"                                                           
## [175] "The Guard"                                                               
## [176] "ATL"                                                                     
## [177] "Coneheads"                                                               
## [178] "Oh God, You Devil!"                                                      
## [179] "Top Secret!"                                                             
## [180] "Weekend Pass"                                                            
## [181] "Punchline"                                                               
## [182] "Night Shift"                                                             
## [183] "High School High"                                                        
## [184] "A Room with a View"                                                      
## [185] "Mr. Baseball"                                                            
## [186] "Short Circuit 2"                                                         
## [187] "The Air Up There"                                                        
## [188] "Eurotrip"                                                                
## [189] "Best in Show"                                                            
## [190] "Cat Ballou"                                                              
## [191] "Walk Hard: The Dewey Cox Story"                                          
## [192] "A Christmas Story"                                                       
## [193] "Things Are Tough All Over"                                               
## [194] "Porky's Revenge"                                                         
## [195] "The Groove Tube"                                                         
## [196] "The Adventures of Ford Fairlane"                                         
## [197] "The Beach Girls"                                                         
## [198] "Some Kind of Hero"                                                       
## [199] "Delhi Belly"                                                             
## [200] "The Incredible Shrinking Woman"                                          
## [201] "Critical Condition"                                                      
## [202] "Six Pack"                                                                
## [203] "Beerfest"                                                                
## [204] "Love and Death"                                                          
## [205] "Another Stakeout"                                                        
## [206] "Multiplicity"                                                            
## [207] "Booty Call"                                                              
## [208] "I Heart Huckabees"                                                       
## [209] "The Life of Brian"                                                       
## [210] "The Adventure of Sherlock Holmes' Smarter Brother"                       
## [211] "The Kentucky Fried Movie"                                                
## [212] "Volunteers"                                                              
## [213] "Melinda and Melinda"                                                     
## [214] "Betsy's Wedding"                                                         
## [215] "Gone Fishin'"                                                            
## [216] "The Cowboy Way"                                                          
## [217] "Summer Catch"                                                            
## [218] "Youth in Revolt"                                                         
## [219] "Pr\x90t-\x88-Porter"                                                     
## [220] "Don't Be a Menace to South Central While Drinking Your Juice in the Hood"
## [221] "Jetsons: The Movie"                                                      
## [222] "View from the Top"                                                       
## [223] "Police Academy 5: Assignment: Miami Beach"                               
## [224] "It Takes Two"                                                            
## [225] "Corrina, Corrina"                                                        
## [226] "House Party 2"                                                           
## [227] "Guan lan"                                                                
## [228] "Dad"                                                                     
## [229] "Little Giants"                                                           
## [230] "Deathtrap"                                                               
## [231] "House Party 3"                                                           
## [232] "The Visitor"                                                             
## [233] "Mother"                                                                  
## [234] "The Odd Couple II"                                                       
## [235] "Alfie"                                                                   
## [236] "Whip It"                                                                 
## [237] "Kazaam"                                                                  
## [238] "Under the Rainbow"                                                       
## [239] "What's New, Pussycat"                                                    
## [240] "Madhouse"                                                                
## [241] "Grande, grosso e Verdone"                                                
## [242] "Hello Again"                                                             
## [243] "Waiting..."                                                              
## [244] "Fired Up"                                                                
## [245] "The Boatniks"                                                            
## [246] "OMG: Oh My God"                                                          
## [247] "Blame it on Rio"                                                         
## [248] "Project X"                                                               
## [249] "A Mighty Wind"                                                           
## [250] "The Curse of the Jade Scorpion"                                          
## [251] "Singles"                                                                 
## [252] "A Thousand Words"                                                        
## [253] "Taking Care of Business"                                                 
## [254] "Hey Baby"                                                                
## [255] "Best Defense"                                                            
## [256] "Sleeper"                                                                 
## [257] "Crimes and Misdemeanors"                                                 
## [258] "That Darn Cat"                                                           
## [259] "Harold & Kumar Go to White Castle"                                       
## [260] "Daddy Day Camp"                                                          
## [261] "Cocoon: The Return"                                                      
## [262] "Dead Men Don't Wear Plaid"                                               
## [263] "Getting Even With Dad"                                                   
## [264] "Skin Deep"                                                               
## [265] "The Sure Thing"                                                          
## [266] "Keeping Mum"                                                             
## [267] "Friends with Money"                                                      
## [268] "Private Lessons"                                                         
## [269] "Everything You Always Wanted to Know"                                    
## [270] "Dope"                                                                    
## [271] "Used People"                                                             
## [272] "Sibling Rivalry"                                                         
## [273] "School for Scoundrels"                                                   
## [274] "The Big Green"                                                           
## [275] "Heavy Weights"                                                           
## [276] "CB4"                                                                     
## [277] "Max Dugan Returns"                                                       
## [278] "Swing Vote"                                                              
## [279] "Hot Dog\xc9 The Movie"                                                   
## [280] "Johnny Be Good"                                                          
## [281] "Rebound"                                                                 
## [282] "My Favorite Year"                                                        
## [283] "Roll Bounce"                                                             
## [284] "And So It Goes"                                                          
## [285] "Born in East L.A."                                                       
## [286] "Sunshine Cleaning"                                                       
## [287] "My Baby's Daddy"                                                         
## [288] "Max Keeble's Big Move"                                                   
## [289] "Half Baked"                                                              
## [290] "Hit & Run"                                                               
## [291] "Her Alibi"                                                               
## [292] "Johnny Dangerously"                                                      
## [293] "Firehouse Dog"                                                           
## [294] "Kung Pow: Enter the Fist"                                                
## [295] "Jury Duty"                                                               
## [296] "Sugar and Spice"                                                         
## [297] "Jaane Tu Ya Jaane Na"                                                    
## [298] "Kiss Kiss, Bang Bang"                                                    
## [299] "Valley Girl"                                                             
## [300] "The Fabulous Baker Boys"                                                 
## [301] "The Good Girl"                                                           
## [302] "Baby's Day Out"                                                          
## [303] "My Girl 2"                                                               
## [304] "National Lampoon's Class Reunion"                                        
## [305] "Heart and Souls"                                                         
## [306] "Candy"                                                                   
## [307] "I Love You, Beth Cooper"                                                 
## [308] "Monkey Trouble"                                                          
## [309] "Burglar"                                                                 
## [310] "Weird Science"                                                           
## [311] "Muppets From Space"                                                      
## [312] "Just Visiting"                                                           
## [313] "Defending Your Life"                                                     
## [314] "D.C. Cab"                                                                
## [315] "Imagine That"                                                            
## [316] "She's Having a Baby"                                                     
## [317] "Flirting with Disaster"                                                  
## [318] "Tyler Perry's The Single Moms Club"                                      
## [319] "Drowning Mona"                                                           
## [320] "Caveman"                                                                 
## [321] "Armed and Dangerous"                                                     
## [322] "Hero At Large"                                                           
## [323] "Ajab Prem Ki Ghazab Kahani"                                              
## [324] "Cai Shen Ke Zhan"                                                        
## [325] "Kiss Me Goodbye"                                                         
## [326] "Double Dhamaal"                                                          
## [327] "Larry the Cable Guy: Health Inspector"                                   
## [328] "Boule et Bill"                                                           
## [329] "I Love You to Death"                                                     
## [330] "Switch"                                                                  
## [331] "Rocket Man"                                                              
## [332] "The Bonfire of the Vanities"                                             
## [333] "Still Smokin"                                                            
## [334] "Mr. Destiny"                                                             
## [335] "She-Devil"                                                               
## [336] "The Goods: Live Hard, Sell Hard"                                         
## [337] "Maiko haaaan!!!"                                                         
## [338] "Quick Change"                                                            
## [339] "First Family"                                                            
## [340] "Miss Pettigrew Lives for a Day"                                          
## [341] "La science des r\x90ves"                                                 
## [342] "Muriel's Wedding"                                                        
## [343] "Bhool Bhulaiyaa"                                                         
## [344] "Zapped!"                                                                 
## [345] "The Front Page"                                                          
## [346] "Matrimonio alle Bahamas"                                                 
## [347] "The Hudsucker Proxy"                                                     
## [348] "Boat Trip"                                                               
## [349] "The Meaning of Life"                                                     
## [350] "S.O.B."                                                                  
## [351] "Once Around"                                                             
## [352] "All I Want For Christmas"                                                
## [353] "Going by the Book"                                                       
## [354] "Ladybugs"                                                                
## [355] "Threesome"                                                               
## [356] "Radio Days"                                                              
## [357] "Out Cold"                                                                
## [358] "The Sixth Man"                                                           
## [359] "Indian Summer"                                                           
## [360] "Men At Work"                                                             
## [361] "Arthur 2: On the Rocks"                                                  
## [362] "Case d\x8epart"                                                          
## [363] "The Nude Bomb"                                                           
## [364] "A Life Less Ordinary"                                                    
## [365] "Enfin Veuve"                                                             
## [366] "Envy"                                                                    
## [367] "Wild at Heart"                                                           
## [368] "Bikur Ha-Tizmoret"                                                       
## [369] "Soul Plane"                                                              
## [370] "Deux jours \x88 Paris"                                                   
## [371] "Oh, God! Book II"                                                        
## [372] "Welcome to Mooseport"                                                    
## [373] "Ishtar"                                                                  
## [374] "Memoirs of an Invisible Man"                                             
## [375] "Hot Rod"                                                                 
## [376] "Surviving Christmas"                                                     
## [377] "Excess Baggage"                                                          
## [378] "The Wizard"                                                              
## [379] "Josie and the Pussycats"                                                 
## [380] "Freddy Got Fingered"                                                     
## [381] "Sweet Liberty"                                                           
## [382] "Wholly Moses!"                                                           
## [383] "Ernest Scared Stupid"                                                    
## [384] "In the Land of Women"                                                    
## [385] "Cool World"                                                              
## [386] "La famille B\x8elier"                                                    
## [387] "Private School"                                                          
## [388] "Def Jam's How To Be a Player"                                            
## [389] "The Bad News Bears Go To Japan"                                          
## [390] "The Survivors"                                                           
## [391] "Charlie and the Chocolate Factory (IMAX)"                                
## [392] "Blues Brothers 2000"                                                     
## [393] "Stealing Harvard"                                                        
## [394] "Sesame Street Presents Follow That Bird"                                 
## [395] "Los amantes pasajeros"                                                   
## [396] "My Stepmother Is an Alien"                                               
## [397] "Angus, Thongs and Perfect Snogging"                                      
## [398] "The Milagro Beanfield War"                                               
## [399] "The Man Who Knew Too Little"                                             
## [400] "Juwanna Mann"                                                            
## [401] "Drop Dead Fred"                                                          
## [402] "The Ladies Man"                                                          
## [403] "Vice Versa"                                                              
## [404] "Spaced Invaders"                                                         
## [405] "Osmosis Jones"                                                           
## [406] "Fear and Loathing in Las Vegas"                                          
## [407] "Trial And Error"                                                         
## [408] "Tomcats"                                                                 
## [409] "The Little Vampire"                                                      
## [410] "The Comebacks"                                                           
## [411] "Charade"                                                                 
## [412] "Sydney White"                                                            
## [413] "Tenacious D in: The Pick of Destiny"                                     
## [414] "One Crazy Summer"                                                        
## [415] "The History Boys"                                                        
## [416] "Clue"                                                                    
## [417] "Mr. Saturday Night"                                                      
## [418] "Koneko monogatari"                                                       
## [419] "La Cage Doree"                                                           
## [420] "Bio-Dome"                                                                
## [421] "Class Act"                                                               
## [422] "Crazy People"                                                            
## [423] "Bullets Over Broadway"                                                   
## [424] "The Honeymooners"                                                        
## [425] "Greedy"                                                                  
## [426] "Author! Author!"                                                         
## [427] "The Ice Pirates"                                                         
## [428] "Senseless"                                                               
## [429] "To Be or Not to Be"                                                      
## [430] "I'm Gonna Git You Sucka"                                                 
## [431] "Crooklyn"                                                                
## [432] "The Crew"                                                                
## [433] "Stroker Ace"                                                             
## [434] "The Pirates Who Don't Do Anything: A VeggieTales Movie"                  
## [435] "Le Divorce"                                                              
## [436] "Bandslam"                                                                
## [437] "Real Genius"                                                             
## [438] "They Call Me Bruce"                                                      
## [439] "The Last Married Couple in America"                                      
## [440] "Unfinished Business"                                                     
## [441] "The Associate"                                                           
## [442] "Weekend at Bernie's II"                                                  
## [443] "Bon Cop, Bad Cop"                                                        
## [444] "Chasing Papi"                                                            
## [445] "While We're Young"                                                       
## [446] "Diner"                                                                   
## [447] "Bachelorette"                                                            
## [448] "Sorority Boys"

Q17

What were the top 5 highest grossing movies after adjusting for inflation? (use the column boxoffice.domestic.inflationadj)

index <- order(m$boxoffice.domestic.inflationadj, decreasing = T)

m <- m[index,]

m[1:5,]
##                                 name boxoffice.total boxoffice.domestic
## 682  Snow White and the Seven Dwarfs       184925485          184925485
## 418                            Bambi       268000000          102797000
## 1490                       Pinocchio        84300000           84300000
## 1504                        Fantasia        83320000           83320000
## 217               Gone with the Wind       390525192          198680470
##      boxoffice.international dvd.domestic  budget rating     genre
## 682                        0           NA 1488000      G   Musical
## 418                165203000           NA       0      G     Drama
## 1490                       0           NA       0      G Adventure
## 1504                       0           NA 2280000      G   Musical
## 217                191844722           NA 3900000      G     Drama
##                creative.type time year production.method sequel
## 682                  Fantasy   83 1937    Hand Animation      0
## 418             Kids Fiction   70 1942    Hand Animation      0
## 1490            Kids Fiction   NA 1940    Hand Animation      0
## 1504 Multiple Creative Types   NA 1940    Hand Animation      0
## 217       Historical Fiction  220 1939       Live Action      0
##      boxoffice.domestic.inflationadj budget.millions
## 682                       6729679608           1.488
## 418                       3151688246           0.000
## 1490                      2927763484           0.000
## 1504                      2893727800           2.280
## 217                       2033987841           3.900
##      boxoffice.total.millions revenue.d.budget boxoffice.millions
## 682                  184.9255        124.27788           184.9255
## 418                  268.0000              Inf           268.0000
## 1490                  84.3000              Inf            84.3000
## 1504                  83.3200         36.54386            83.3200
## 217                  390.5252        100.13466           390.5252

In what years were these movies made?

m$year[1:5]
## [1] 1937 1942 1940 1940 1939