knitr::opts_chunk$set( collapse = TRUE, comment = "#>")
library(R.vengers) library(tidyverse) library(ggplot2)
Welcome to the R.vengers package! Below, users will find instructions on how to use functions to return information about movies, tv-series, or games. - The 'Table of Functions' provides a brief summary of each function in this package. - Additionally, a detailed tutorial with examples is provided with each function.
| Function | Description |
|:--|:-----|
| avengers_movies
| returns a dataframe with information of all Marvel Avengers movies |
| get_top10_recommendations
| returns a dataframe of the top 10 recommended movies/tv-series based on specified genre |
| surprise_me
| returns a dataframe with titles and information to a random list of movies/tv-series based on specified genre |
| get_actors
| returns a dataframe with a column containing the actors of a movie, tv-series, or game |
| get_awards
| returns a dataframe with a column containing the awards won by a movie, tv-series, or game |
| get_director
| returns a dataframe with a column containing the director(s) of a movie, tv-series, or game |
| get_genre
| returns a dataframe with a column containing the genre(s) of a movie, tv-series, or game |
| get_poster
| returns a dataframe with a column containing the link to a visual poster of a movie, tv-series, or game |
| get_rating
| returns a dataframe with a column containing the IMDB Rating of a movie, tv-series, or game |
| get_runtime
| returns a dataframe with a column containing the runtime of a movie, tv-series, or game |
| get_writer
| returns a dataframe with a column containing the writer(s) of a movie, tv-series, or game |
| read_plot
| returns a dataframe with a column containing the full plot of a movie, tv-series, or game |
| search_all
| returns a dataframe with attributes and information to a list of movies, tv-series, or games |
avengers_movies()
returns a dataframe of all Marvel Avengers movies.
avengers_movies()
| Title | Type | Year | Genre | Runtime (in minutes) | Actors | Director | Awards | IMDB Rating |
|---:|---:|---:|---:|---:|---:|---:|---:|---:|
|$
get_top10_recommendations(genre)
returns a dataframe of the top 10 recommended movies or tv-series based on the specified genre.
get_top10_recommendations("animation")
| Title | Type | Year | Genre | Runtime (in minutes) | Actors | Director | Awards | IMDB Rating |
|-:|-:|-:|-:|-:|-:|-:|-:|-:|
| $
surprise_me(genre)
returns a dataframe with information to 5 random movies of the specified genre.
surprise_me()
| Title | Type | Year | Genre | Runtime (in minutes) | Actors | Director | Awards | IMDB Rating |
|-:|-:|-:|-:|-:|-:|-:|-:|-:|
| $
get_actors(search_text, type)
returns a dataframe with a column providing information about the actors of a movie, tv-series, or game.
get_actors("guardians galaxy")
| Title | Type | Year | Actors |
|-----:|-:|-:|-----:|
| $
get_awards(search_text, type)
returns a dataframe with a column providing information about awards won by a movie, tv-series, or game.
get_awards("guardians galaxy")
| Title | Type | Year | Director |
|-----:|-:|-:|-----:|
| $
get_director(search_text, type)
returns a dataframe with a column providing information about the director(s) of a movie, tv-series, or game.
get_director("guardians galaxy")
| Title | Type | Year | Director |
|-----:|-----:|-----:|-----:|
| $
get_genre(search_text, type)
returns a dataframe with a column providing information about the genre(s) of a movie, tv-series, or game.
get_genre("guardians")
| Title | Type | Year | Genre |
|-----:|-:|-:|-----:|
| $
get_poster(search_text, type)
returns a dataframe with a column containing the link to a visual poster of the movie, tv-series, or game.
get_poster("guardians galaxy")
| Title | Type | Year | Poster (link) |
|-----:|-:|-:|-----:|
| $
get_rating(search_text, type)
returns a dataframe with a column containing the IMDB Rating of a movie, tv-series, or game.
get_rating("guardians")
| Title | Type | Year | IMDB Rating |
|-----:|-----:|-----:|-----:|
| $
get_runtime(search_text, type)
returns a dataframe with a column containing the runtime of a movie, tv-series, or game.
get_runtime("guardians")
| Title | Type | Year | Runtime (in minutes) |
|-----:|-----:|-----:|-----:|
| $
get_writer(search_text, type)
returns a dataframe with a column containing the writers of a movie, tv-series, or game.
get_writer("guardians galaxy")
| Title | Type | Year | Writer |
|-----:|-----:|-----:|-----:|
| $
read_plot(search_text, type, plot)
returns a dataframe with a column containing the plot of a movie, tv-series, or game.
short
or full
.full
plot as a default.read_plot("guardians")
| Title | Type | Year | Plot |
|-----:|-----:|-----:|-----:|
| $
search_all(search_text, type)
returns a dataframe with attributes based on searched movies, tv-series, or games.
search_all("guardians galaxy")
| Title | Type | Year | Genre | Runtime (in minutes) | Actors | Director | Awards | IMDB Rating |
|-:|-:|-:|-:|-:|-:|-:|-:|-:|
| $
# load the result of the avengers_movies() function into a dataframe df_avengers <- avengers_movies()
# scatter plot of ratings with(df_avengers, plot(Year, `IMDB Rating`, main = "Rating of Avengers movies over time", xlab = 'Year', ylab = "Rating"))
# Team Ironman - Movies & Ratings team_iron_man <- df_avengers[c(1,3,7,16,18), c(1,9)] names(team_iron_man)[2] <- "Rating" team_iron_man
# Team Captain America - Movies & Ratings team_captain_america <- df_avengers[c(5,9,12,13,20), c(1,9)] names(team_captain_america)[2] <- "Rating" team_captain_america
# Civil War ratings_team_iron_man <- NA ratings_team_captain_america <- NA for(fight in 1:20) { ratings_team_iron_man[fight] <- sample(team_iron_man$Rating, 1) ratings_team_captain_america[fight] <- sample(team_captain_america$Rating, 1) } civil_war = data.frame("fight" = 1:20, "team_ironman" = ratings_team_iron_man, "team_cap" = ratings_team_captain_america) df_civil_war <- civil_war %>% select(fight, team_ironman, team_cap) %>% gather(key = "team", value = "score", -fight)
# Line Plot of scores for all head-to-head movie rating fights (comparisons) ggplot(df_civil_war, aes(x = fight, y = score)) + geom_line(aes(color = team)) + scale_color_manual(values = c("darkred", "steelblue")) + ylim(6, 9)
# Who won the Civil War mini-game? results <- data.frame(table(ratings_team_captain_america > ratings_team_iron_man)) names(results)[1] <- "Team" names(results)[2] <- "Wins" results$Team <- as.character(results$Team) results$Team[results$Team == 'TRUE'] <- "Team_Cap" results$Team[results$Team == 'FALSE'] <- "Team_Ironman" results
# Visualization of Results g <- ggplot(results, aes(Team)) + geom_bar(aes(weight = Wins, fill = Team)) g + theme(legend.position = "top") + xlab("") + ylab("# of wins") + labs(fill = "")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.