Upload the file to Github and read the file from Github

tv_url<- "https://raw.githubusercontent.com/jayleecunysps/AssignmentforSPS/main/Dataset_Superhero-TV-Shows.csv"
tvdata <-read.csv(tv_url)

Clean the data, selet and join

tvworkingdata <- tvdata %>%  
select("show_title","imdb_rating","release_year","runtime","genre","parental_guideline")

tvworkingdata$imdb_rating <-as.numeric(tvworkingdata$imdb_rating)
## Warning: NAs introduced by coercion
tvworkingdata$runtime <-as.numeric(tvworkingdata$runtime)
## Warning: NAs introduced by coercion
tvworkingdata <- tvworkingdata %>% filter_at(vars(2), any_vars(. > 0)) #remove NA
tvworkingdata <- tvworkingdata %>% filter_at(vars(4), any_vars(. > 0)) 

tvworkingdata$release_year <- str_extract(tvworkingdata$release_year, "^\\d{4}")

head(tvworkingdata,20)
##                   show_title imdb_rating release_year runtime
## 1                 Peacemaker         8.5         2022      40
## 2  The Legend of Vox Machina         8.6         2022      30
## 3                  Daredevil         8.6         2015      54
## 4                   The Boys         8.7         2019      60
## 5               Raising Dion         7.2         2019      50
## 6                     Titans         7.6         2018      45
## 7  Star Wars: The Clone Wars         8.3         2008      23
## 8               The Punisher         8.5         2017      53
## 9                  The Flash         7.6         2014      43
## 10           Superman & Lois         7.9         2021      42
## 11      The Umbrella Academy         8.0         2019      60
## 12    Agents of S.H.I.E.L.D.         7.5         2013      45
## 13               What If...?         7.5         2021      32
## 14                    Gotham         7.8         2014      42
## 15                     Arrow         7.5         2012      42
## 16                Invincible         8.7         2021      50
## 17             Jessica Jones         7.9         2015      56
## 18  DC's Legends of Tomorrow         6.8         2016      42
## 19               Doom Patrol         7.9         2019      60
## 20         Star Wars: Rebels         8.0         2014      22
##                           genre parental_guideline
## 1     Action, Adventure, Comedy              TV-MA
## 2  Animation, Action, Adventure              TV-MA
## 3          Action, Crime, Drama              TV-MA
## 4          Action, Crime, Drama              TV-MA
## 5                 Drama, Sci-Fi               TV-G
## 6      Action, Adventure, Crime              TV-MA
## 7  Animation, Action, Adventure              TV-PG
## 8          Action, Crime, Drama              TV-MA
## 9      Action, Adventure, Drama              TV-PG
## 10     Action, Adventure, Drama              TV-14
## 11    Action, Adventure, Comedy              TV-14
## 12     Action, Adventure, Drama              TV-PG
## 13 Animation, Action, Adventure              TV-14
## 14         Action, Crime, Drama              TV-14
## 15     Action, Adventure, Crime              TV-14
## 16 Animation, Action, Adventure              TV-MA
## 17         Action, Crime, Drama              TV-MA
## 18     Action, Adventure, Drama              TV-14
## 19    Action, Adventure, Comedy              TV-MA
## 20 Animation, Action, Adventure           TV-Y7-FV

Answer of the Deepa Sharma’s suggested analysis

What is the highest-rated TV show of each year.

1950s to early 1960s, you can still see family as high rated TV show, however, action plus adventure is the most popular combo.

What is the highest rated TV show from each category in the data set.

I pick parental guidelines since action and adventure (Superhero you know) are always the most high rated Superhero TV show.

The highest show is TV-MA (TV Mature Audience) and lowest is TV-Y (suitable for all children).

it totally make sense since has less limit which mean the show can be more different content than TV-Y.

TV-Y may not be a good direction for hero related TV shows or Movie.

lets listen what parent said about our fave Marvel movie.

“All of the Marvel movies are rated PG-13, so they will all have some element that is technically not suitable for young children. That being said, some of them have less violence and more language, or less violence and more language, or some sexual content.” by Meet Tania

ref: https://lolalambchops.com/most-kid-friendly-marvel-movies/#:~:text=All%20of%20the%20Marvel%20movies,language%2C%20or%20some%20sexual%20content.

tvworkingdatayr <- tvworkingdata[order(tvworkingdata$release_year,tvworkingdata$imdb_rating, decreasing = TRUE), ]

tvworkingdatayrtop <- Reduce(rbind,                                 
                    by(tvworkingdatayr,
                       tvworkingdatayr["release_year"],
                       head,
                       n = 1))
tvworkingdatayrtop
##                                     show_title imdb_rating release_year runtime
## 193                            The Lone Ranger         7.7         1949      30
## 604                                 Dick Tracy         7.6         1950      30
## 122                     Adventures of Superman         7.7         1952      30
## 552 Commando Cody: Sky Marshal of the Universe         6.0         1953      30
## 518                           Captain Midnight         8.0         1954      30
## 483                Sheena: Queen of the Jungle         6.9         1955      28
## 189                                      Zorro         8.2         1957      30
## 503                          The Invisible Man         7.3         1958      30
## 458                          Quick Draw McGraw         6.8         1959      30
## 365                          Popeye the Sailor         7.1         1960      30
## 90                                The Avengers         8.3         1961      60
## 95                                   The Saint         7.5         1962      50
## 567                                  Astro Boy         7.4         1963      30
## 251                                Jonny Quest         7.8         1964      30
## 106                                  Get Smart         8.2         1965      25
## 514                            The Lone Ranger         7.7         1966      30
## 530                                 Ultraseven         8.2         1967      30
## 316                              The Champions         7.6         1968      60
## 124                 Scooby Doo, Where Are You!         7.9         1969      22
## 203                       The Electric Company         8.1         1971      28
## 521                                  Gatchaman         7.8         1972      25
## 449                       El Chapulín Colorado         8.5         1973      25
## 102                 The Six Million Dollar Man         7.1         1974      60
## 84                                Wonder Woman         7.1         1975      60
## 435                              Monster Squad         7.7         1976      30
## 513             The All-New Super Friends Hour         7.2         1977      60
## 336                      Battle of the Planets         7.6         1978      30
## 496                               Flash Gordon         7.0         1979      30
## 631                                 Chespirito         8.1         1980      60
## 325                               Danger Mouse         7.4         1981      25
## 50                                Knight Rider         6.9         1982      46
## 536                                     Perman         8.1         1983      15
## 210                                 Robin Hood         8.4         1984      60
## 366                                   Robotech         8.5         1985      30
## 485                        Journey to the West         8.7         1986      45
## 546                          Kamen Rider Black         8.2         1987      25
## 472                             Ronin Warriors         7.4         1988      23
## 55                               Dragon Ball Z         8.7         1989      24
## 590                         Samurai Pizza Cats         7.4         1990      30
## 618                      Choujin Sentai Jetman         8.3         1991      25
## 45                 Batman: The Animated Series         9.0         1992      23
## 373            Swat Kats: The Radical Squadron         8.4         1993      22
## 81             Spider-Man: The Animated Series         8.4         1994      23
## 165                                Dragon Ball         8.5         1995      24
## 199                            Rurouni Kenshin         8.4         1996      24
## 143                  The New Batman Adventures         8.5         1997      30
## 47                                Cowboy Bebop         8.9         1998      24
## 115                              Batman Beyond         8.1         1999      23
## 264            Harvey Birdman, Attorney at Law         8.0         2000      15
## 93                                Samurai Jack         8.5         2001      25
## 196    Ghost in the Shell: Stand Alone Complex         8.5         2002      24
## 112                        Fullmetal Alchemist         8.5         2003      24
## 116                   Justice League Unlimited         8.7         2004      23
## 21                  Avatar: The Last Airbender         9.3         2005      23
## 338                               Frisky Dingo         8.1         2006      11
## 27                           Naruto: Shippûden         8.6         2007      24
## 7                    Star Wars: The Clone Wars         8.3         2008      23
## 32            Fullmetal Alchemist: Brotherhood         9.1         2009      24
## 38                               Young Justice         8.7         2010      23
## 509                    Kaizoku Sentai Gokaiger         8.5         2011      25
## 30                    JoJo's Bizarre Adventure         8.5         2012      30
## 71                             Steven Universe         8.1         2013      11
## 20                           Star Wars: Rebels         8.0         2014      22
## 35                               One Punch Man         8.7         2015      24
## 86                              Mob Psycho 100         8.6         2016      24
## 8                                 The Punisher         8.5         2017      53
## 98          She-Ra and the Princesses of Power         7.8         2018      30
## 4                                     The Boys         8.7         2019      60
## 511                    Mashin Sentai Kiramager         8.0         2020      25
## 16                                  Invincible         8.7         2021      50
## 2                    The Legend of Vox Machina         8.6         2022      30
##                            genre parental_guideline
## 193                      Western               TV-G
## 604                        Drama                   
## 122     Action, Adventure, Crime               TV-G
## 552    Action, Adventure, Sci-Fi                   
## 518                       Sci-Fi               TV-G
## 483                    Adventure                   
## 189           Adventure, Western               TV-G
## 503      Drama, Sci-Fi, Thriller                   
## 458    Animation, Comedy, Family               TV-G
## 365 Animation, Adventure, Comedy               TV-G
## 90         Action, Comedy, Crime              TV-14
## 95          Action, Crime, Drama              TV-PG
## 567 Animation, Action, Adventure              TV-Y7
## 251 Animation, Action, Adventure              TV-Y7
## 106    Action, Adventure, Comedy               TV-G
## 514   Animation, Family, Western                   
## 530     Action, Adventure, Drama              TV-PG
## 316  Adventure, Sci-Fi, Thriller                   
## 124 Animation, Adventure, Comedy               TV-G
## 203               Family, Comedy               TV-G
## 521 Animation, Action, Adventure              TV-PG
## 449      Comedy, Family, Fantasy              TV-PG
## 102         Action, Crime, Drama              TV-PG
## 84    Action, Adventure, Fantasy               TV-G
## 435    Adventure, Family, Horror                   
## 513 Animation, Action, Adventure                   
## 336 Animation, Action, Adventure              TV-Y7
## 496 Animation, Action, Adventure              TV-Y7
## 631        Comedy, Crime, Family              TV-PG
## 325    Animation, Comedy, Family               TV-Y
## 50          Action, Crime, Drama              TV-PG
## 536 Animation, Action, Adventure              TV-Y7
## 210       Action, Drama, Fantasy              TV-PG
## 366 Animation, Action, Adventure              TV-Y7
## 485            Action, Adventure                   
## 546     Action, Adventure, Drama              TV-PG
## 472 Animation, Action, Adventure              PG-13
## 55  Animation, Action, Adventure              TV-PG
## 590    Animation, Action, Comedy              TV-Y7
## 618    Action, Adventure, Comedy              TV-14
## 45  Animation, Action, Adventure              TV-PG
## 373    Animation, Action, Family              TV-PG
## 81  Animation, Action, Adventure               TV-Y
## 165 Animation, Action, Adventure              TV-14
## 199 Animation, Action, Adventure              TV-14
## 143 Animation, Action, Adventure              TV-PG
## 47  Animation, Action, Adventure              TV-14
## 115 Animation, Action, Adventure              TV-Y7
## 264    Animation, Comedy, Sci-Fi              TV-14
## 93  Animation, Action, Adventure              TV-14
## 196     Animation, Action, Crime              TV-MA
## 112 Animation, Action, Adventure              TV-PG
## 116 Animation, Action, Adventure           TV-Y7-FV
## 21  Animation, Action, Adventure           TV-Y7-FV
## 338    Animation, Comedy, Sci-Fi              TV-MA
## 27  Animation, Action, Adventure              TV-PG
## 7   Animation, Action, Adventure              TV-PG
## 32  Animation, Action, Adventure              TV-14
## 38  Animation, Action, Adventure              TV-PG
## 509    Action, Adventure, Comedy              TV-PG
## 30  Animation, Action, Adventure              TV-14
## 71  Animation, Action, Adventure              TV-PG
## 20  Animation, Action, Adventure           TV-Y7-FV
## 35     Animation, Action, Comedy              TV-PG
## 86     Animation, Action, Comedy              TV-14
## 8           Action, Crime, Drama              TV-MA
## 98  Animation, Action, Adventure           TV-Y7-FV
## 4           Action, Crime, Drama              TV-MA
## 511    Action, Adventure, Comedy              TV-PG
## 16  Animation, Action, Adventure              TV-MA
## 2   Animation, Action, Adventure              TV-MA
tvworkingdatatype <- tvworkingdata[order(tvworkingdata$parental_guideline, decreasing = TRUE), ]

tvworkingdatatypetop <- Reduce(rbind,                                 
                    by(tvworkingdatatype,
                       tvworkingdatatype["parental_guideline"],
                       head,
                       n = 1))
tvworkingdatatypetop
##                                  show_title imdb_rating release_year runtime
## 92                            Bad and Crazy         8.3         2021      70
## 125                              Shaktimaan         8.2         1997      60
## 472                          Ronin Warriors         7.4         1988      23
## 287             Constantine: City of Demons         7.6         2018       6
## 10                          Superman & Lois         7.9         2021      42
## 5                              Raising Dion         7.2         2019      50
## 1                                Peacemaker         8.5         2022      40
## 7                 Star Wars: The Clone Wars         8.3         2008      23
## 68                               PAW Patrol         6.1         2013      23
## 22  Miraculous: Tales of Ladybug & Cat Noir         7.7         2015      20
## 20                        Star Wars: Rebels         8.0         2014      22
##                            genre parental_guideline
## 92         Action, Comedy, Crime                   
## 125    Action, Adventure, Family          Not Rated
## 472 Animation, Action, Adventure              PG-13
## 287     Animation, Short, Action                  R
## 10      Action, Adventure, Drama              TV-14
## 5                  Drama, Sci-Fi               TV-G
## 1      Action, Adventure, Comedy              TV-MA
## 7   Animation, Action, Adventure              TV-PG
## 68  Animation, Adventure, Comedy               TV-Y
## 22  Animation, Action, Adventure              TV-Y7
## 20  Animation, Action, Adventure           TV-Y7-FV