Assignment 3: Data Wrangling

Author: Brooke Comito

Date: 2025-03-17

Load necessary libraries

library(dplyr) library(readr)

Load the movies dataset

movies <- read_csv(“https://gist.githubusercontent.com/tiangechen/b68782efa49a16edaf07dc2cdaa855ea/raw/0c794a9717f18b094eabab2cd6a6b9a226903577/movies.csv”)

View the first few rows

head(movies)

Step 1: Data Cleaning & Transformation

movies_final <- movies %>% rename(movie_title = Film, release_year = Year) %>% select(movie_title, release_year, Genre, Profitability, Rotten Tomatoes %) %>% filter(release_year > 2000, Rotten Tomatoes % > 80) %>% mutate(Profitability_millions = Profitability / 1e6) %>% arrange(desc(Rotten Tomatoes %), desc(Profitability_millions))

View the transformed dataset

head(movies_final)

——————————————-

Answering the Questions

——————————————-

Question 1: Are the best-rated movies also the most profitable?

Answer:

Looking at the sorted data, high ratings do not always mean high profitability.

For example:

- “WALL-E” has the highest Rotten Tomatoes % (96%) but low profitability (2.90 million).

- “Midnight in Paris” (93%) and “Enchanted” (93%) have moderate profits.

- “Knocked Up” (91%) has higher profitability.

Conclusion:

The best-rated movies are not necessarily the most profitable.

While high Rotten Tomatoes scores indicate critical acclaim, financial success is influenced

by factors such as marketing, production budget, and audience reach.

——————————————-

Extra Credit: Average Ratings & Profitability by Genre

——————————————-

movies_summary <- movies_final %>% group_by(Genre) %>% summarize( avg_rating = mean(Rotten Tomatoes %, na.rm = TRUE), avg_profit_millions = mean(Profitability_millions, na.rm = TRUE) )

View the summary results

head(movies_summary)

Observations:

- Animation and Comedy genres tend to have higher average profitability.

- Drama and Romance tend to have higher Rotten Tomatoes ratings but lower profitability.

- This suggests that some critically acclaimed genres may not always be the most commercially successful.

——————————————-

Final Thoughts:

——————————————-

This analysis shows that movie success is not solely based on ratings but also on financial factors.

While high Rotten Tomatoes scores indicate critical success, profitability depends on variables

such as production cost, distribution strategy, and audience appeal.