Install packages

install.packages("ggplot2")
install.packages("dplyr")

Library loading

library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## 
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## 
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Loading the “Movies” Dataset

data(movies)
df <- movies
head(df)
##                      title year length budget rating votes   r1   r2  r3
## 1                        $ 1971    121     NA    6.4   348  4.5  4.5 4.5
## 2        $1000 a Touchdown 1939     71     NA    6.0    20  0.0 14.5 4.5
## 3   $21 a Day Once a Month 1941      7     NA    8.2     5  0.0  0.0 0.0
## 4                  $40,000 1996     70     NA    8.2     6 14.5  0.0 0.0
## 5 $50,000 Climax Show, The 1975     71     NA    3.4    17 24.5  4.5 0.0
## 6                    $pent 2000     91     NA    4.3    45  4.5  4.5 4.5
##     r4   r5   r6   r7   r8   r9  r10 mpaa Action Animation Comedy Drama
## 1  4.5 14.5 24.5 24.5 14.5  4.5  4.5           0         0      1     1
## 2 24.5 14.5 14.5 14.5  4.5  4.5 14.5           0         0      1     0
## 3  0.0  0.0 24.5  0.0 44.5 24.5 24.5           0         1      0     0
## 4  0.0  0.0  0.0  0.0  0.0 34.5 45.5           0         0      1     0
## 5 14.5 14.5  4.5  0.0  0.0  0.0 24.5           0         0      0     0
## 6 14.5 14.5 14.5  4.5  4.5 14.5 14.5           0         0      0     1
##   Documentary Romance Short
## 1           0       0     0
## 2           0       0     0
## 3           0       0     1
## 4           0       0     0
## 5           0       0     0
## 6           0       0     0

Plotting a histogram

p <- ggplot(df, aes(rating))

p + geom_histogram()
## stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.

p <- ggplot(df, aes(votes))

p + geom_histogram()
## stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.

p <- ggplot(df, aes(budget))

p + geom_histogram()
## stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.

Making a scatter plot

Are well rated movies more expensive ?

p <- ggplot(df, aes(rating, budget))

p + geom_point()
## Warning: Removed 53573 rows containing missing values (geom_point).

Filtering the good movies (rated higher than 8)

good <- filter(df, rating > 8)

What are the best movies ?

best <- filter(df, rating == 10)
best$title
## [1] "Dimensia Minds Trilogy: The Hope Factor"
## [2] "Fishing for Love"                       
## [3] "Summer Sonata, A"

Let’s be more inclusive

best <- filter(df, rating > 9.8)
best$title
##  [1] "Black Canyon"                           
##  [2] "Buck Privates"                          
##  [3] "Defilada"                               
##  [4] "Dimensia Minds Trilogy: The Hope Factor"
##  [5] "Dimensia Minds Trilogy: The Reds"       
##  [6] "Drifting"                               
##  [7] "Ekdromi, I"                             
##  [8] "Fishing for Love"                       
##  [9] "Genet parle d'Angela Davis"             
## [10] "Himala"                                 
## [11] "Ivan Groznyy III"                       
## [12] "Keeper of the Past"                     
## [13] "New World, The"                         
## [14] "Of Age"                                 
## [15] "Penis Envy"                             
## [16] "Phantom Submarine, The"                 
## [17] "Plight of Clownana, The"                
## [18] "Shades"                                 
## [19] "Shopping Part, The"                     
## [20] "Sky of an Archangel"                    
## [21] "Summer Sonata, A"                       
## [22] "Titanic vals"                           
## [23] "Tosca"

What are the worst movies ?

worst <- filter(df, rating == 0)
worst$title
## character(0)

What are the worst movies ?

worst <- filter(df, rating <=1.2)
worst$title
##   [1] "20/20 Vision"                                          
##   [2] "A.D.3 operazione squalo bianco"                        
##   [3] "Affairs of Janice"                                     
##   [4] "Al Adamson: Drive-In Monster"                          
##   [5] "American Flatulators"                                  
##   [6] "Assignment: Venezuela"                                 
##   [7] "Aventures galantes de Zorro, Les"                      
##   [8] "Babo 73"                                               
##   [9] "Bak syv hav"                                           
##  [10] "Balls Bluff"                                           
##  [11] "Bell, Bare and Beautiful"                              
##  [12] "Bengelchen liebt kreuz und quer"                       
##  [13] "Beyond the Wall of Sleep"                              
##  [14] "Black Love"                                            
##  [15] "Black Sherlock Holmes, A"                              
##  [16] "Blair Fish Project, The"                               
##  [17] "Blonde Frau des Maharadscha, Die"                      
##  [18] "Boin-n-g"                                              
##  [19] "Bono"                                                  
##  [20] "Boxer, The"                                            
##  [21] "Brand of Shame"                                        
##  [22] "Cadet Classification"                                  
##  [23] "Carabinieri si nasce"                                  
##  [24] "Cartas de amor de una monja"                           
##  [25] "Casa de las muertas vivientes, La"                     
##  [26] "Chainsaw Sally"                                        
##  [27] "Champions Forever: The Latin Legends"                  
##  [28] "Chepor, La"                                            
##  [29] "Christmas on Earth"                                    
##  [30] "Cielo no perdona, El"                                  
##  [31] "Clive Barker's Freakz"                                 
##  [32] "College Girls"                                         
##  [33] "Colt era il suo Dio, La"                               
##  [34] "Commuter Husbands"                                     
##  [35] "Creepees vs. Robot Monster Number Two, The"            
##  [36] "Daughter of the Sun"                                   
##  [37] "Deadwait"                                              
##  [38] "Death Driver"                                          
##  [39] "Death May Be Your Santa Claus"                         
##  [40] "Death Riders"                                          
##  [41] "Demolition Highway"                                    
##  [42] "Desperate Women, The"                                  
##  [43] "Dharkan"                                               
##  [44] "Dibu 2: La venganza de Nasty"                          
##  [45] "Dos locos en el aire"                                  
##  [46] "Doughboys in Ireland"                                  
##  [47] "Dr. Strange Glove"                                     
##  [48] "Dream Follies"                                         
##  [49] "Du Elvis, Ich Monroe"                                  
##  [50] "Ecstasies of Women, The"                               
##  [51] "Effects"                                               
##  [52] "Elle voulait faire quelque chose"                      
##  [53] "Elvis"                                                 
##  [54] "Elvis & June: A Love Story"                            
##  [55] "Emotional Backgammon"                                  
##  [56] "Er was eens... Luna"                                   
##  [57] "Europe in the Raw"                                     
##  [58] "Exotic Dreams of Casanova, The"                        
##  [59] "Face on the Bar-Room Floor, The"                       
##  [60] "Fleurs de Maria Papadopylou, Les"                      
##  [61] "For Singles Only"                                      
##  [62] "Franzmann"                                             
##  [63] "Fratello dello spazio"                                 
##  [64] "Free Country the Movie"                                
##  [65] "G.I. Executioner"                                      
##  [66] "Half Way to Hell"                                      
##  [67] "Heavenly Bodies!"                                      
##  [68] "Hemmelig sommer"                                       
##  [69] "Hippy Hippy Sex"                                       
##  [70] "Hippy Porn"                                            
##  [71] "Hollywood Dreams Take 2"                               
##  [72] "Hollywood's World of Flesh"                            
##  [73] "Home Invaders"                                         
##  [74] "How I Learned to Stop Worrying and Love the Superlaser"
##  [75] "How to Succeed with Sex"                               
##  [76] "Ireland, a Nation"                                     
##  [77] "Irish Destiny"                                         
##  [78] "Irish Whiskey"                                         
##  [79] "Irish and Proud of It"                                 
##  [80] "Jersey Guy"                                            
##  [81] "Joey's Christmas"                                      
##  [82] "John Wayne: Bigger Than Life"                          
##  [83] "Jungen Tiger von Hongkong, Die"                        
##  [84] "Kappert 1: Die Briefmarke"                             
##  [85] "Kappert 1: Die Briefmarke - Das Remake"                
##  [86] "Kappert 2: Die Photos"                                 
##  [87] "Kappert 3: Willkommen Europa"                          
##  [88] "Kappert 4: Irish Brass"                                
##  [89] "Kathleen Mavourneen"                                   
##  [90] "Kerl liebt mich - und das soll ich glauben?, Der"      
##  [91] "Las Vegas Serial Killer"                               
##  [92] "Las Vegas Weekend"                                     
##  [93] "Last American Hobo, The"                               
##  [94] "Legend of Blood Mountain, The"                         
##  [95] "Leni Riefenstahl im Sudan"                             
##  [96] "Linda and Abilene"                                     
##  [97] "Little Irish Girl, The"                                
##  [98] "Living Venus"                                          
##  [99] "Locuras del extraterrestre, Las"                       
## [100] "Loft Tapes: Student Films From Notre Dame, The"        
## [101] "Lost"                                                  
## [102] "Luck of the Irish, The"                                
## [103] "Luck of the Irish, The"                                
## [104] "Lucky: The Irish Pimp"                                 
## [105] "Luna caliente"                                         
## [106] "Mache alles mit"                                       
## [107] "Magic Spectacles"                                      
## [108] "Making of 'Invasion of the Freedom Snatchers', The"    
## [109] "Marca del muerto, La"                                  
## [110] "Mark of the Devil 666: The Moralist"                   
## [111] "Meeting, The"                                          
## [112] "Men of Ireland"                                        
## [113] "Menthe - la bienheureuse"                              
## [114] "Merry Christmas Deutschland"                           
## [115] "Mission: Africa"                                       
## [116] "Mondo Keyhole"                                         
## [117] "Morten Korch - Solskin kan man altid finde"            
## [118] "Motel Confidential"                                    
## [119] "Mummy and the Curse of the Jackals, The"               
## [120] "My Dear Uncle Sherlock"                                
## [121] "My Life with Count Dracula"                            
## [122] "Naked Camera, The"                                     
## [123] "Napoleon's Barber"                                     
## [124] "Natas: The Reflection"                                 
## [125] "Nature's Playmates"                                    
## [126] "Niets bijzonders"                                      
## [127] "Ninja Vs. Bruce Lee"                                   
## [128] "No More Excuses"                                       
## [129] "Obscuratio"                                            
## [130] "Off Islanders"                                         
## [131] "Office Love-in, White-Collar Style"                    
## [132] "Phinehas"                                              
## [133] "Pirates"                                               
## [134] "Pizzaiolo et Mozzarel"                                 
## [135] "Planet of the Pitts"                                   
## [136] "Pride of Ireland"                                      
## [137] "Puppet"                                                
## [138] "Rachel's Man"                                          
## [139] "Reality of Life"                                       
## [140] "Return of Sherlock Holmes, The"                        
## [141] "Roaming the Emerald Isle"                              
## [142] "Sarg aus Hongkong, Ein"                                
## [143] "Saturday Night Sleazies, Vol. 1"                       
## [144] "Saturday Night Sleazies, Vol. 2"                       
## [145] "Serpent Island"                                        
## [146] "Sex Perils of Paulette, The"                           
## [147] "Shadowlands"                                           
## [148] "Sherlock Holmes und die sieben Zwerge"                 
## [149] "Sherlock Sleuth"                                       
## [150] "Sherlock de Araque"                                    
## [151] "Shocktroop"                                            
## [152] "Shoot Yourself Some Golf"                              
## [153] "Sidste detalje, Den"                                   
## [154] "Skyscrapers and Brassieres"                            
## [155] "Smiling Irish Eyes"                                    
## [156] "Stand-Up Reagan"                                       
## [157] "Steckler Interviews"                                   
## [158] "Sticks and Bones"                                      
## [159] "Street-Fighter"                                        
## [160] "Strong Boy"                                            
## [161] "Suburban Roulette"                                     
## [162] "Suburban Wives"                                        
## [163] "Suburbia Confidential"                                 
## [164] "Sweet Smell of Sex"                                    
## [165] "Tender Loving Care"                                    
## [166] "Tia Juana After Midnite"                               
## [167] "Tony Blair Witch Project, The"                         
## [168] "Torpedo Squadron"                                      
## [169] "Touch of Greatness, A"                                 
## [170] "Treasure of Alpheus T. Winterborn, The"                
## [171] "Trident Force"                                         
## [172] "Ultimo volo all'inferno, L'"                           
## [173] "Under Age"                                             
## [174] "Unearthed"                                             
## [175] "Untamed Women"                                         
## [176] "Vacanza, La"                                           
## [177] "Vampire Blvd."                                         
## [178] "Vente a ligar al Oeste"                                
## [179] "Vicious Years, The"                                    
## [180] "Wacky World of Dr. Morgus, The"                        
## [181] "What's Up Front!"                                      
## [182] "Why Elvis?"                                            
## [183] "Wild Ones on Wheels"                                   
## [184] "Windsplitter, The"                                     
## [185] "Xuxa e os Duendes 2 - No caminho das Fadas"            
## [186] "www.XXX.com"

What are the best known movies ?

famous <- filter(df, votes >= 50000)
famous$title
##  [1] "2001: A Space Odyssey"                                               
##  [2] "Alien"                                                               
##  [3] "Aliens"                                                              
##  [4] "American Beauty"                                                     
##  [5] "American History X"                                                  
##  [6] "Apocalypse Now"                                                      
##  [7] "Back to the Future"                                                  
##  [8] "Being John Malkovich"                                                
##  [9] "Big Lebowski, The"                                                   
## [10] "Blade Runner"                                                        
## [11] "Braveheart"                                                          
## [12] "Casablanca"                                                          
## [13] "Citizen Kane"                                                        
## [14] "Clockwork Orange, A"                                                 
## [15] "Die Hard"                                                            
## [16] "Donnie Darko"                                                        
## [17] "Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb"
## [18] "Fargo"                                                               
## [19] "Fifth Element, The"                                                  
## [20] "Fight Club"                                                          
## [21] "Forrest Gump"                                                        
## [22] "Gladiator"                                                           
## [23] "Godfather, The"                                                      
## [24] "Godfather: Part II, The"                                             
## [25] "Good Will Hunting"                                                   
## [26] "Goodfellas"                                                          
## [27] "Green Mile, The"                                                     
## [28] "Independence Day"                                                    
## [29] "Indiana Jones and the Last Crusade"                                  
## [30] "Jurassic Park"                                                       
## [31] "Kill Bill: Vol. 1"                                                   
## [32] "L.A. Confidential"                                                   
## [33] "Lord of the Rings: The Fellowship of the Ring, The"                  
## [34] "Lord of the Rings: The Return of the King, The"                      
## [35] "Lord of the Rings: The Two Towers, The"                              
## [36] "Matrix Reloaded, The"                                                
## [37] "Matrix, The"                                                         
## [38] "Memento"                                                             
## [39] "Men in Black"                                                        
## [40] "Minority Report"                                                     
## [41] "Monty Python and the Holy Grail"                                     
## [42] "One Flew Over the Cuckoo's Nest"                                     
## [43] "Pirates of the Caribbean: The Curse of the Black Pearl"              
## [44] "Princess Bride, The"                                                 
## [45] "Psycho"                                                              
## [46] "Pulp Fiction"                                                        
## [47] "Raiders of the Lost Ark"                                             
## [48] "Reservoir Dogs"                                                      
## [49] "Saving Private Ryan"                                                 
## [50] "Schindler's List"                                                    
## [51] "Se7en"                                                               
## [52] "Shawshank Redemption, The"                                           
## [53] "Shining, The"                                                        
## [54] "Shrek"                                                               
## [55] "Silence of the Lambs, The"                                           
## [56] "Sixth Sense, The"                                                    
## [57] "Spider-Man"                                                          
## [58] "Star Wars"                                                           
## [59] "Star Wars: Episode I - The Phantom Menace"                           
## [60] "Star Wars: Episode II - Attack of the Clones"                        
## [61] "Star Wars: Episode V - The Empire Strikes Back"                      
## [62] "Star Wars: Episode VI - Return of the Jedi"                          
## [63] "Terminator 2: Judgment Day"                                          
## [64] "Terminator, The"                                                     
## [65] "Titanic"                                                             
## [66] "Trainspotting"                                                       
## [67] "Truman Show, The"                                                    
## [68] "Twelve Monkeys"                                                      
## [69] "Usual Suspects, The"                                                 
## [70] "Wo hu cang long"

Let’s rank them by popularity

poprank <- famous[order(famous$vote),]
poprank$title
##  [1] "Big Lebowski, The"                                                   
##  [2] "Shining, The"                                                        
##  [3] "Minority Report"                                                     
##  [4] "Trainspotting"                                                       
##  [5] "Donnie Darko"                                                        
##  [6] "Wo hu cang long"                                                     
##  [7] "Men in Black"                                                        
##  [8] "Princess Bride, The"                                                 
##  [9] "Psycho"                                                              
## [10] "Being John Malkovich"                                                
## [11] "Fifth Element, The"                                                  
## [12] "Matrix Reloaded, The"                                                
## [13] "Jurassic Park"                                                       
## [14] "Die Hard"                                                            
## [15] "American History X"                                                  
## [16] "Terminator, The"                                                     
## [17] "Green Mile, The"                                                     
## [18] "Monty Python and the Holy Grail"                                     
## [19] "Pirates of the Caribbean: The Curse of the Black Pearl"              
## [20] "Good Will Hunting"                                                   
## [21] "Citizen Kane"                                                        
## [22] "Indiana Jones and the Last Crusade"                                  
## [23] "Independence Day"                                                    
## [24] "Twelve Monkeys"                                                      
## [25] "Truman Show, The"                                                    
## [26] "Spider-Man"                                                          
## [27] "Alien"                                                               
## [28] "Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb"
## [29] "Star Wars: Episode II - Attack of the Clones"                        
## [30] "Aliens"                                                              
## [31] "Apocalypse Now"                                                      
## [32] "2001: A Space Odyssey"                                               
## [33] "Kill Bill: Vol. 1"                                                   
## [34] "Shrek"                                                               
## [35] "Clockwork Orange, A"                                                 
## [36] "Fargo"                                                               
## [37] "Casablanca"                                                          
## [38] "Goodfellas"                                                          
## [39] "Back to the Future"                                                  
## [40] "Reservoir Dogs"                                                      
## [41] "L.A. Confidential"                                                   
## [42] "One Flew Over the Cuckoo's Nest"                                     
## [43] "Godfather: Part II, The"                                             
## [44] "Blade Runner"                                                        
## [45] "Terminator 2: Judgment Day"                                          
## [46] "Star Wars: Episode VI - Return of the Jedi"                          
## [47] "Star Wars: Episode I - The Phantom Menace"                           
## [48] "Se7en"                                                               
## [49] "Forrest Gump"                                                        
## [50] "Titanic"                                                             
## [51] "Memento"                                                             
## [52] "Silence of the Lambs, The"                                           
## [53] "Braveheart"                                                          
## [54] "Gladiator"                                                           
## [55] "Raiders of the Lost Ark"                                             
## [56] "Sixth Sense, The"                                                    
## [57] "Schindler's List"                                                    
## [58] "Saving Private Ryan"                                                 
## [59] "Lord of the Rings: The Return of the King, The"                      
## [60] "Star Wars: Episode V - The Empire Strikes Back"                      
## [61] "Usual Suspects, The"                                                 
## [62] "American Beauty"                                                     
## [63] "Fight Club"                                                          
## [64] "Lord of the Rings: The Two Towers, The"                              
## [65] "Godfather, The"                                                      
## [66] "Pulp Fiction"                                                        
## [67] "Star Wars"                                                           
## [68] "Matrix, The"                                                         
## [69] "Shawshank Redemption, The"                                           
## [70] "Lord of the Rings: The Fellowship of the Ring, The"

Let’s rank them by rating

ratingrank <- famous[order(famous$rating),]
ratingrank$title
##  [1] "Independence Day"                                                    
##  [2] "Star Wars: Episode I - The Phantom Menace"                           
##  [3] "Men in Black"                                                        
##  [4] "Titanic"                                                             
##  [5] "Star Wars: Episode II - Attack of the Clones"                        
##  [6] "Fifth Element, The"                                                  
##  [7] "Matrix Reloaded, The"                                                
##  [8] "Jurassic Park"                                                       
##  [9] "Spider-Man"                                                          
## [10] "Truman Show, The"                                                    
## [11] "Good Will Hunting"                                                   
## [12] "Minority Report"                                                     
## [13] "Being John Malkovich"                                                
## [14] "Terminator, The"                                                     
## [15] "Twelve Monkeys"                                                      
## [16] "Big Lebowski, The"                                                   
## [17] "Die Hard"                                                            
## [18] "Gladiator"                                                           
## [19] "Pirates of the Caribbean: The Curse of the Black Pearl"              
## [20] "Shrek"                                                               
## [21] "Trainspotting"                                                       
## [22] "Back to the Future"                                                  
## [23] "Green Mile, The"                                                     
## [24] "Indiana Jones and the Last Crusade"                                  
## [25] "Star Wars: Episode VI - Return of the Jedi"                          
## [26] "Blade Runner"                                                        
## [27] "Fargo"                                                               
## [28] "Forrest Gump"                                                        
## [29] "Princess Bride, The"                                                 
## [30] "Sixth Sense, The"                                                    
## [31] "Terminator 2: Judgment Day"                                          
## [32] "Wo hu cang long"                                                     
## [33] "2001: A Space Odyssey"                                               
## [34] "Alien"                                                               
## [35] "Aliens"                                                              
## [36] "Braveheart"                                                          
## [37] "Clockwork Orange, A"                                                 
## [38] "Donnie Darko"                                                        
## [39] "Kill Bill: Vol. 1"                                                   
## [40] "Reservoir Dogs"                                                      
## [41] "Saving Private Ryan"                                                 
## [42] "Shining, The"                                                        
## [43] "American History X"                                                  
## [44] "L.A. Confidential"                                                   
## [45] "Monty Python and the Holy Grail"                                     
## [46] "Se7en"                                                               
## [47] "American Beauty"                                                     
## [48] "Apocalypse Now"                                                      
## [49] "Fight Club"                                                          
## [50] "Matrix, The"                                                         
## [51] "Silence of the Lambs, The"                                           
## [52] "Goodfellas"                                                          
## [53] "Psycho"                                                              
## [54] "Citizen Kane"                                                        
## [55] "Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb"
## [56] "Memento"                                                             
## [57] "One Flew Over the Cuckoo's Nest"                                     
## [58] "Raiders of the Lost Ark"                                             
## [59] "Usual Suspects, The"                                                 
## [60] "Casablanca"                                                          
## [61] "Lord of the Rings: The Fellowship of the Ring, The"                  
## [62] "Lord of the Rings: The Two Towers, The"                              
## [63] "Pulp Fiction"                                                        
## [64] "Schindler's List"                                                    
## [65] "Star Wars"                                                           
## [66] "Star Wars: Episode V - The Empire Strikes Back"                      
## [67] "Godfather: Part II, The"                                             
## [68] "Lord of the Rings: The Return of the King, The"                      
## [69] "Godfather, The"                                                      
## [70] "Shawshank Redemption, The"

By default, we rank by ascending order

To rank by descending order, we add a - sign

Ascending

ratingrank <- famous[order(famous$rating),]

Descending

ratingrank <- famous[order(-famous$rating),]
ratingrank$title
##  [1] "Godfather, The"                                                      
##  [2] "Shawshank Redemption, The"                                           
##  [3] "Lord of the Rings: The Return of the King, The"                      
##  [4] "Godfather: Part II, The"                                             
##  [5] "Casablanca"                                                          
##  [6] "Lord of the Rings: The Fellowship of the Ring, The"                  
##  [7] "Lord of the Rings: The Two Towers, The"                              
##  [8] "Pulp Fiction"                                                        
##  [9] "Schindler's List"                                                    
## [10] "Star Wars"                                                           
## [11] "Star Wars: Episode V - The Empire Strikes Back"                      
## [12] "Citizen Kane"                                                        
## [13] "Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb"
## [14] "Memento"                                                             
## [15] "One Flew Over the Cuckoo's Nest"                                     
## [16] "Raiders of the Lost Ark"                                             
## [17] "Usual Suspects, The"                                                 
## [18] "Goodfellas"                                                          
## [19] "Psycho"                                                              
## [20] "American Beauty"                                                     
## [21] "Apocalypse Now"                                                      
## [22] "Fight Club"                                                          
## [23] "Matrix, The"                                                         
## [24] "Silence of the Lambs, The"                                           
## [25] "American History X"                                                  
## [26] "L.A. Confidential"                                                   
## [27] "Monty Python and the Holy Grail"                                     
## [28] "Se7en"                                                               
## [29] "2001: A Space Odyssey"                                               
## [30] "Alien"                                                               
## [31] "Aliens"                                                              
## [32] "Braveheart"                                                          
## [33] "Clockwork Orange, A"                                                 
## [34] "Donnie Darko"                                                        
## [35] "Kill Bill: Vol. 1"                                                   
## [36] "Reservoir Dogs"                                                      
## [37] "Saving Private Ryan"                                                 
## [38] "Shining, The"                                                        
## [39] "Blade Runner"                                                        
## [40] "Fargo"                                                               
## [41] "Forrest Gump"                                                        
## [42] "Princess Bride, The"                                                 
## [43] "Sixth Sense, The"                                                    
## [44] "Terminator 2: Judgment Day"                                          
## [45] "Wo hu cang long"                                                     
## [46] "Back to the Future"                                                  
## [47] "Green Mile, The"                                                     
## [48] "Indiana Jones and the Last Crusade"                                  
## [49] "Star Wars: Episode VI - Return of the Jedi"                          
## [50] "Big Lebowski, The"                                                   
## [51] "Die Hard"                                                            
## [52] "Gladiator"                                                           
## [53] "Pirates of the Caribbean: The Curse of the Black Pearl"              
## [54] "Shrek"                                                               
## [55] "Trainspotting"                                                       
## [56] "Being John Malkovich"                                                
## [57] "Terminator, The"                                                     
## [58] "Twelve Monkeys"                                                      
## [59] "Good Will Hunting"                                                   
## [60] "Minority Report"                                                     
## [61] "Truman Show, The"                                                    
## [62] "Jurassic Park"                                                       
## [63] "Spider-Man"                                                          
## [64] "Fifth Element, The"                                                  
## [65] "Matrix Reloaded, The"                                                
## [66] "Star Wars: Episode II - Attack of the Clones"                        
## [67] "Titanic"                                                             
## [68] "Men in Black"                                                        
## [69] "Star Wars: Episode I - The Phantom Menace"                           
## [70] "Independence Day"
head(ratingrank)
##                                                 title year length   budget
## 23                                     Godfather, The 1972    175  6000000
## 52                          Shawshank Redemption, The 1994    142 25000000
## 34     Lord of the Rings: The Return of the King, The 2003    251 94000000
## 24                            Godfather: Part II, The 1974    200 13000000
## 12                                         Casablanca 1942    102   950000
## 33 Lord of the Rings: The Fellowship of the Ring, The 2001    208 93000000
##    rating  votes  r1  r2  r3  r4  r5  r6  r7   r8   r9  r10  mpaa Action
## 23    9.1 122755 4.5 4.5 4.5 4.5 4.5 4.5 4.5 14.5 14.5 45.5            0
## 52    9.1 149494 4.5 4.5 4.5 4.5 4.5 4.5 4.5 14.5 24.5 45.5     R      0
## 34    9.0 103631 4.5 4.5 4.5 4.5 4.5 4.5 4.5  4.5 14.5 64.5 PG-13      1
## 24    8.9  71363 4.5 4.5 4.5 4.5 4.5 4.5 4.5 14.5 24.5 44.5            0
## 12    8.8  66030 4.5 4.5 4.5 4.5 4.5 4.5 4.5 14.5 24.5 44.5            0
## 33    8.8 157608 4.5 4.5 4.5 4.5 4.5 4.5 4.5 14.5 14.5 45.5 PG-13      1
##    Animation Comedy Drama Documentary Romance Short
## 23         0      0     1           0       0     0
## 52         0      0     1           0       0     0
## 34         0      0     0           0       0     0
## 24         0      0     1           0       0     0
## 12         0      0     1           0       1     0
## 33         0      0     0           0       0     0

If we only want to keep a few variables (title, year, rating, votes)

We have to use the “select” function from the dplyr package

df2 <- select(ratingrank, title, year, rating, votes)

head(df2)
##                                                 title year rating  votes
## 23                                     Godfather, The 1972    9.1 122755
## 52                          Shawshank Redemption, The 1994    9.1 149494
## 34     Lord of the Rings: The Return of the King, The 2003    9.0 103631
## 24                            Godfather: Part II, The 1974    8.9  71363
## 12                                         Casablanca 1942    8.8  66030
## 33 Lord of the Rings: The Fellowship of the Ring, The 2001    8.8 157608

The best unknown movies

What are the best unknown movies ?

unknown <- filter(df, votes < 100 & rating >= 9.5)
unknownrank <- unknown[order(-unknown$rating),]
unknownrank$title
##   [1] "Dimensia Minds Trilogy: The Hope Factor"                                                                                  
##   [2] "Fishing for Love"                                                                                                         
##   [3] "Summer Sonata, A"                                                                                                         
##   [4] "Black Canyon"                                                                                                             
##   [5] "Buck Privates"                                                                                                            
##   [6] "Defilada"                                                                                                                 
##   [7] "Dimensia Minds Trilogy: The Reds"                                                                                         
##   [8] "Drifting"                                                                                                                 
##   [9] "Ekdromi, I"                                                                                                               
##  [10] "Genet parle d'Angela Davis"                                                                                               
##  [11] "Himala"                                                                                                                   
##  [12] "Ivan Groznyy III"                                                                                                         
##  [13] "Keeper of the Past"                                                                                                       
##  [14] "New World, The"                                                                                                           
##  [15] "Of Age"                                                                                                                   
##  [16] "Penis Envy"                                                                                                               
##  [17] "Phantom Submarine, The"                                                                                                   
##  [18] "Plight of Clownana, The"                                                                                                  
##  [19] "Shades"                                                                                                                   
##  [20] "Shopping Part, The"                                                                                                       
##  [21] "Sky of an Archangel"                                                                                                      
##  [22] "Titanic vals"                                                                                                             
##  [23] "Tosca"                                                                                                                    
##  [24] "Cashback"                                                                                                                 
##  [25] "Ceniciento, El"                                                                                                           
##  [26] "Challenge"                                                                                                                
##  [27] "Chibideka monogatari"                                                                                                     
##  [28] "Clase z tropical"                                                                                                         
##  [29] "Click Three Times"                                                                                                        
##  [30] "Clown"                                                                                                                    
##  [31] "Complex Sessions, The"                                                                                                    
##  [32] "Copi, je t'aime"                                                                                                          
##  [33] "Distinto amanecer"                                                                                                        
##  [34] "Dolor de pagar la renta, El"                                                                                              
##  [35] "Drive-by Shooting"                                                                                                        
##  [36] "Ennio Morricone: la musica negli occhi"                                                                                   
##  [37] "Evil Surprise, The"                                                                                                       
##  [38] "Freaks Uncensored!"                                                                                                       
##  [39] "Gardiens de phare"                                                                                                        
##  [40] "Gene Autry, Melody of the West"                                                                                           
##  [41] "Glissando"                                                                                                                
##  [42] "Goodnite Charlie"                                                                                                         
##  [43] "Handicap"                                                                                                                 
##  [44] "I Am My Resume"                                                                                                           
##  [45] "Ina, kapatid, anak"                                                                                                       
##  [46] "Innocence Project, The"                                                                                                   
##  [47] "Island, The"                                                                                                              
##  [48] "Ixe"                                                                                                                      
##  [49] "Jagadeka Veeruni Katha"                                                                                                   
##  [50] "Kitchen Soup for the Soul"                                                                                                
##  [51] "Kom tillbaka"                                                                                                             
##  [52] "Leng mian hu"                                                                                                             
##  [53] "Martin Four"                                                                                                              
##  [54] "Meet the Stars: Meet Roy Rogers"                                                                                          
##  [55] "Milton Is a Shitbag"                                                                                                      
##  [56] "Mimmo & Paulie"                                                                                                           
##  [57] "Miracle des loups, Le"                                                                                                    
##  [58] "Moonlight in Vermont"                                                                                                     
##  [59] "Mumi-troll i drugie"                                                                                                      
##  [60] "Names of Sin"                                                                                                             
##  [61] "Nozze di Figaro, Le"                                                                                                      
##  [62] "Nun Fu"                                                                                                                   
##  [63] "Oath, The"                                                                                                                
##  [64] "Out of Our Dens: The Richard and the Young Lions Story"                                                                   
##  [65] "Outside"                                                                                                                  
##  [66] "Peaceable Kingdom"                                                                                                        
##  [67] "Pee Shy"                                                                                                                  
##  [68] "Pelli Chesi Choodu"                                                                                                       
##  [69] "Rain, Drizzle, and Fog"                                                                                                   
##  [70] "Safar barlek"                                                                                                             
##  [71] "Self Defense... for Cowards"                                                                                              
##  [72] "Silent Whispers"                                                                                                          
##  [73] "Snegurochka"                                                                                                              
##  [74] "Soul to Soul"                                                                                                             
##  [75] "Start of Something, The"                                                                                                  
##  [76] "Strange Aeons"                                                                                                            
##  [77] "Taking Tiger Mountain"                                                                                                    
##  [78] "TankUp.US"                                                                                                                
##  [79] "Text of Light, The"                                                                                                       
##  [80] "There's Something About a Soldier"                                                                                        
##  [81] "Three Barbecues: A Blackened Comedy"                                                                                      
##  [82] "Three of Us, The"                                                                                                         
##  [83] "Tie Xi Qu: West of the Tracks - Part 3: Rails"                                                                            
##  [84] "Trial of Jack, The"                                                                                                       
##  [85] "Victim, The"                                                                                                              
##  [86] "Weg ist das Spiel, Der"                                                                                                   
##  [87] "BattleGround: 21 Days on the Empire's Edge"                                                                               
##  [88] "Berlin Berlin"                                                                                                            
##  [89] "Blind"                                                                                                                    
##  [90] "Cape of Good Hope"                                                                                                        
##  [91] "Car Trouble"                                                                                                              
##  [92] "Causality"                                                                                                                
##  [93] "Celebration: The Music of Pete Townshend and The Who"                                                                     
##  [94] "Cerebrium"                                                                                                                
##  [95] "Chernov/Chernov"                                                                                                          
##  [96] "Custodial Code, The"                                                                                                      
##  [97] "David Nelson Live"                                                                                                        
##  [98] "Derniers feux"                                                                                                            
##  [99] "Dozen Kliks, A"                                                                                                           
## [100] "En la palma de tu mano"                                                                                                   
## [101] "Familia de tantas, Una"                                                                                                   
## [102] "Family Portrait"                                                                                                          
## [103] "Garriage: A Documentary in 4 Chapters and an Epilogue"                                                                    
## [104] "Hammer and Cycle"                                                                                                         
## [105] "Here After"                                                                                                               
## [106] "Home Improvements"                                                                                                        
## [107] "Itim"                                                                                                                     
## [108] "Judy Garland in Concert"                                                                                                  
## [109] "Kamiondzije opet voze"                                                                                                    
## [110] "Kan Zeh Lo Sham"                                                                                                          
## [111] "Ketchup and Mustard Man, The"                                                                                             
## [112] "Kommunist"                                                                                                                
## [113] "Konyok-gorbunok"                                                                                                          
## [114] "MGM Sarajevo: Covjek, Bog, Monstrum"                                                                                      
## [115] "Memories of War"                                                                                                          
## [116] "Mi Puerto Rico"                                                                                                           
## [117] "Miami"                                                                                                                    
## [118] "Missed Call"                                                                                                              
## [119] "Morphin(e)"                                                                                                               
## [120] "Normal Love"                                                                                                              
## [121] "North of Providence"                                                                                                      
## [122] "Offering, The"                                                                                                            
## [123] "Original Schtick"                                                                                                         
## [124] "Oscura noche"                                                                                                             
## [125] "Out-of-Body Experience"                                                                                                   
## [126] "P mesle pelican"                                                                                                          
## [127] "Pachanga, La"                                                                                                             
## [128] "Perfect Location, The"                                                                                                    
## [129] "Portile albastre ale orasului"                                                                                            
## [130] "Pudeur ou l'impudeur, La"                                                                                                 
## [131] "Quincy's Quest"                                                                                                           
## [132] "Razor Eaters"                                                                                                             
## [133] "Shoe Store, The"                                                                                                          
## [134] "Silver Bells"                                                                                                             
## [135] "Sledvay me"                                                                                                               
## [136] "Strangers"                                                                                                                
## [137] "Thanks for Nothing"                                                                                                       
## [138] "That Lady From Peking"                                                                                                    
## [139] "Throwing Down"                                                                                                            
## [140] "Tupperware!"                                                                                                              
## [141] "Young Gentlemen"                                                                                                          
## [142] "Adaptatziya"                                                                                                              
## [143] "Akatsuki no dasso"                                                                                                        
## [144] "Anyone"                                                                                                                   
## [145] "Apartment 206"                                                                                                            
## [146] "Army of One"                                                                                                              
## [147] "Aufbruch, Der"                                                                                                            
## [148] "Ballad of Courtney & James, The"                                                                                          
## [149] "Biyaya ng lupa"                                                                                                           
## [150] "Blaze Orange"                                                                                                             
## [151] "Bunker - Die letzten Tage"                                                                                                
## [152] "C'est le vent"                                                                                                            
## [153] "Chords of Fame"                                                                                                           
## [154] "Clarks"                                                                                                                   
## [155] "Class of 83"                                                                                                              
## [156] "Classic Queen"                                                                                                            
## [157] "Coffee & Donuts"                                                                                                          
## [158] "Cog"                                                                                                                      
## [159] "Croaziera"                                                                                                                
## [160] "Deedar"                                                                                                                   
## [161] "Devil Talk"                                                                                                               
## [162] "Doing Time, Doing Vipassana"                                                                                              
## [163] "Driving Fish"                                                                                                             
## [164] "Eternal Embrace"                                                                                                          
## [165] "Filmic Achievement"                                                                                                       
## [166] "Focus"                                                                                                                    
## [167] "Goodnight Bill"                                                                                                           
## [168] "Hand of Fate"                                                                                                             
## [169] "Harry Chapin: The Final Concert"                                                                                          
## [170] "Historia de un gran amor"                                                                                                 
## [171] "Hopscotch"                                                                                                                
## [172] "Igazi Mao, Az"                                                                                                            
## [173] "In Their Absence"                                                                                                         
## [174] "Karl May"                                                                                                                 
## [175] "King of the Hill"                                                                                                         
## [176] "Krylya"                                                                                                                   
## [177] "Lachenite obuvki na neznayniya voin"                                                                                      
## [178] "Man Who Invented the Moon"                                                                                                
## [179] "Maso et Miso vont en bateau"                                                                                              
## [180] "Matelas, Le"                                                                                                              
## [181] "Menq enq, mer sarere"                                                                                                     
## [182] "Mission: Space"                                                                                                           
## [183] "Missy"                                                                                                                    
## [184] "Mr Firecul"                                                                                                               
## [185] "Mukta"                                                                                                                    
## [186] "Mutual Admiration Society"                                                                                                
## [187] "Nahapet"                                                                                                                  
## [188] "Nicole's Revenge"                                                                                                         
## [189] "One Dog Day"                                                                                                              
## [190] "Otra, La"                                                                                                                 
## [191] "Paperchase in Berlin"                                                                                                     
## [192] "Paris minuit"                                                                                                             
## [193] "Pleasure Pill"                                                                                                            
## [194] "Point Five"                                                                                                               
## [195] "Put More Blood Into the Music"                                                                                            
## [196] "Quintrala, La"                                                                                                            
## [197] "Rent's Due"                                                                                                               
## [198] "Rokoko"                                                                                                                   
## [199] "Sandcastles"                                                                                                              
## [200] "Satsujin kyo jidai"                                                                                                       
## [201] "Screw"                                                                                                                    
## [202] "Shao Lin san shi liu zhu"                                                                                                 
## [203] "Silencio"                                                                                                                 
## [204] "Skazki... skazki... skazki starogo Arbata"                                                                                
## [205] "Snookles"                                                                                                                 
## [206] "Sveto mesto"                                                                                                              
## [207] "Sylvia, rimembri ancora?"                                                                                                 
## [208] "Tailspin Tommy in The Great Air Mystery"                                                                                  
## [209] "Tasty"                                                                                                                    
## [210] "Tis kakomoiras"                                                                                                           
## [211] "To Render a Life"                                                                                                         
## [212] "TransAmazon: A Gender Queer Journey"                                                                                      
## [213] "Trollywood"                                                                                                               
## [214] "Two Days with Juliet"                                                                                                     
## [215] "Western"                                                                                                                  
## [216] "Whistlin' Dixie"                                                                                                          
## [217] "Wild Girls Gone"                                                                                                          
## [218] "Allegro ma non troppo"                                                                                                    
## [219] "America 101"                                                                                                              
## [220] "Bari Theke Paliye"                                                                                                        
## [221] "Bear Country"                                                                                                             
## [222] "Bona"                                                                                                                     
## [223] "Boy"                                                                                                                      
## [224] "Breathing Lessons: The Life and Work of Mark O'Brien"                                                                     
## [225] "Buck Nelson Presents: Lifting the Cloak of Mystery Off Rock Drumming"                                                     
## [226] "Byalata staya"                                                                                                            
## [227] "Da no tien gu"                                                                                                            
## [228] "Descent"                                                                                                                  
## [229] "Diary of a Bad Lad"                                                                                                       
## [230] "Empty Building, The"                                                                                                      
## [231] "Epic Tale of Kalesius and Clotho: A Meditation on the Impossibility of Romantic Love in a Rapidly Expanding Universe, The"
## [232] "Epilog"                                                                                                                   
## [233] "Era outra vez"                                                                                                            
## [234] "Focus Group"                                                                                                              
## [235] "Gundamma Katha"                                                                                                           
## [236] "Happy Ending"                                                                                                             
## [237] "Herkus mantas"                                                                                                            
## [238] "His Highness Abdullah"                                                                                                    
## [239] "Home for the Bullets, A"                                                                                                  
## [240] "Iarna bobocilor"                                                                                                          
## [241] "Incredible Manitoba Animation"                                                                                            
## [242] "Ister, The"                                                                                                               
## [243] "Kiga kaikyo"                                                                                                              
## [244] "Kiss on the Nose, A"                                                                                                      
## [245] "Lebewohl, Fremde"                                                                                                         
## [246] "Legend of the Boy and the Eagle, The"                                                                                     
## [247] "Maman que man"                                                                                                            
## [248] "Marienthal: State of Emergency"                                                                                           
## [249] "Merika"                                                                                                                   
## [250] "Message From Moonbase Alpha"                                                                                              
## [251] "Missionary Positions"                                                                                                     
## [252] "Mond im Skorpion"                                                                                                         
## [253] "Monster Road"                                                                                                             
## [254] "Moondram Pirai"                                                                                                           
## [255] "Nadodikkattu"                                                                                                             
## [256] "Nemuri Kyoshiro 3: Engetsugiri"                                                                                           
## [257] "Neurosia - 50 Jahre pervers"                                                                                              
## [258] "Night of the Dog"                                                                                                         
## [259] "Offering, The"                                                                                                            
## [260] "Okkadu"                                                                                                                   
## [261] "Overtime"                                                                                                                 
## [262] "Painted Door, The"                                                                                                        
## [263] "Piggy Bank"                                                                                                               
## [264] "Pillowfight"                                                                                                              
## [265] "Planetata na sakrovishtata"                                                                                               
## [266] "Preservation"                                                                                                             
## [267] "Prodigy, The"                                                                                                             
## [268] "Punto y raya"                                                                                                             
## [269] "Raggedy Ann and Raggedy Andy"                                                                                             
## [270] "Reasonable Hypothesis, A"                                                                                                 
## [271] "Ride, The"                                                                                                                
## [272] "Right Here, Right Now"                                                                                                    
## [273] "Sagara Sangamam"                                                                                                          
## [274] "Sailor in the Wild"                                                                                                       
## [275] "Scomparsa"                                                                                                                
## [276] "Sexual Ecstasy of the Macumba"                                                                                            
## [277] "Shyamchi Aai"                                                                                                             
## [278] "Silent Call, The"                                                                                                         
## [279] "Simitrio"                                                                                                                 
## [280] "Simulacrum"                                                                                                               
## [281] "State of Wonder"                                                                                                          
## [282] "Sundown"                                                                                                                  
## [283] "Superstition"                                                                                                             
## [284] "Swingin' in the Painter's Room"                                                                                           
## [285] "Taffy Was Born"                                                                                                           
## [286] "Tea with Tiffany"                                                                                                         
## [287] "Tie Xi Qu: West of the Tracks - Part 1: Rust"                                                                             
## [288] "Tie Xi Qu: West of the Tracks - Part 2: Remnants"                                                                         
## [289] "To Be Alive!"                                                                                                             
## [290] "Two Lords"                                                                                                                
## [291] "Un festin d'amis"                                                                                                         
## [292] "What Is Funny?"                                                                                                           
## [293] "Wide Asleep"                                                                                                              
## [294] "Young Americans"

See you in two weeks