To begin, I wanted to get a general idea of the type of numbers I was working with. First I wanted to see how many genres of books were in this data set.
#table of genres and counts
genres_table <- table(book_sales$genre)
genres_table_sorted <- genres_table[order(genres_table, decreasing = TRUE)]
genres_table_sorted
##
## fiction nonfiction children
## 884 171 15
The data set only features 3 genres of books: fiction, nonfiction, and children books. The frequency of fiction books in this data set greatly outnumbers the count of both nonfiction and children’s books. Due to this data being fairly limited, I did not quite see a reason to investigate this futher.
Next, I wanted to take a look at the publishers and get an idea of how many publishers there were in this data set, and how many books each had published.
#table of publishers and books published
publishers_table <- table(book_sales$Publisher)
publishers_table_sorted <- publishers_table[order(publishers_table, decreasing = TRUE)]
publishers_table_sorted
##
## Amazon Digital Services, Inc. Random House LLC
## 600 120
## Penguin Group (USA) LLC HarperCollins Publishers
## 108 79
## Hachette Book Group Simon and Schuster Digital Sales Inc
## 66 56
## Macmillan
## 41
Amazon Digital Services, Inc. had the highest number of books published by far, while Macmillan had the fewest number of published books in this data set.
Next, I wanted to begin taking a look at sales, including the number of units sold and gross sales procured.
#summary statistics of units sold across all books and publishers
summary(book_sales$`units sold`)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 106.0 551.2 3924.0 9677.0 5312.2 61560.0
A numeric summary of units sold identified 106 as the minimum number of units sold, and 61560 as the maximum number of units sold. This gave me a general idea of the spread of data regarding the number of units sold.
Following this, I wanted to examine the number of units sold by each publisher, along with their gross sales.
publisher_sales <- book_sales |>
#group all sales by publisher
group_by(Publisher) |>
#gather sum of units sold and gross sales for each book
summarise(total_units_sold = sum(`units sold`),
total_gross_sales = sum(`gross sales`)) |>
#arrange by units sold descending
arrange(desc(total_units_sold))
publisher_sales
## # A tibble: 7 × 3
## Publisher total_units_sold total_gross_sales
## <chr> <dbl> <dbl>
## 1 Amazon Digital Services, Inc. 6074136 729809.
## 2 Random House LLC 1315958 315975.
## 3 Penguin Group (USA) LLC 934303 356362.
## 4 HarperCollins Publishers 649294 222408.
## 5 Hachette Book Group 543821 229791.
## 6 Simon and Schuster Digital Sales Inc 501928 78314.
## 7 Macmillan 334929 53927.
Amazon Digital Services, Inc had the highest number of books sold and the highest gross sales total, but I was interested in a few instances where a publisher who sold less had more gross sales than a publisher who sold more. This can be seen with Penguin Group (USA) LLC and Random House LLC, where despite Random House LLC selling several thousand more books than Penguin Group, Penguin group overtook them in their gross sales total.
In order to more easily visualize the total number of units sold and the total gross sales, I wanted to use grouped bar charts for each publisher.
ggplot(publisher_sales, aes(x = Publisher)) +
#creates units sold bar, stat identity for sum, position dodge for grouped bar charts
geom_bar(aes(y = total_units_sold, fill = "Units Sold"),
stat = "identity", position = "dodge") +
#creates total gross sales bar
geom_bar(aes(y = total_gross_sales, fill = "Gross Sales"),
stat = "identity", position = "dodge", alpha = 0.7) +
#titles
labs(title = "Total Units Sold and Total Gross Sales by Publisher",
x = "Publisher",
y = "Value") +
scale_fill_manual(values = c("coral1","aquamarine3")) +
theme(axis.text.x = element_text(angle=45, hjust=1)) +
#abbreviates labels on x axis and sets a length for each label
scale_x_discrete(labels = abbreviate(publisher_sales$Publisher, minlength = 10))
With this visualization, it is easier to see that Random House LLC sold quite a few more books than Penguin Group (USA) LLC, yet had less gross sales. A similar phenomenon can be seen with Harper Collins Publishing and Hachette Book Group. I have a few questions regarding this:
- What is the distribution of sales price for books across these publishers?
- Is this an occurrence that happened slowly happened over time, or is it the result of any certain event such as the release of a certain book?
- If this is the result of a book, how do the ratings, sales, and cost of that book compare to those same vectors of other books?
I decided that a box and whisker plot would be a good method for analyzing distributions for these two publishers
#compare random house and penguin group
publishers_to_compare <- c("Random House LLC", "Penguin Group (USA) LLC")
#selects publisher and sale price for the publishers needing to compare
selected_publishers_data <- book_sales |>
filter(Publisher %in% publishers_to_compare) |>
select(Publisher, `sale price`)
#box plot
ggplot(selected_publishers_data, aes(x = Publisher, y = `sale price`)) +
geom_boxplot(fill = "aquamarine3", color = "black", alpha = 0.7, outlier.color = "red") +
labs(title = "Sales Price Distribution for Random House LLC and Penguin Group (USA) LLC",
x = "Publisher",
y = "Sales Price") +
theme_classic()
The medians of the two plots are incredibly close to each other, although they both have slightly different distributions. Penguin Group (USA) LLC seems to be slightly more positively-skewed, where as Random House LLC is a bit more negatively skewed. Both have at least one outlier, and Random House LLC seems to have a bit larger of a distribution overall.
publishers_to_compare <- c("Random House LLC", "Penguin Group (USA) LLC")
#selects publisher, publishing year, and gross sales for publishers needing to be compared
selected_publishers_data <- book_sales |>
filter(Publisher %in% publishers_to_compare) |>
select(Publisher, `Publishing Year`, `gross sales`)
#filtered to years > 2000 because there were a few books listed from hundreds of years ago
filtered_data <- selected_publishers_data |>
filter(`Publishing Year` >= 2000)
#line graphs
ggplot(filtered_data, aes(x = `Publishing Year`,
y = `gross sales`, color = `Publisher`)) +
geom_line() +
labs(title = "Gross Sales Over Time for Random House and Penguin Group ",
x = "Publishing Year",
y = "Gross Sales",
color = "Publisher") +
theme_minimal()
Looking at the gross sales over time for each of the publishers, both publishers have several spikes in their yearly gross sales. Notably, Penguin Group has a very large spike around 2010 - 2011.
#since spike in penguin sales is right after 2010, filter for this and sort descending by sales to find to book
penguin_sales_data <- book_sales |>
filter(Publisher == "Penguin Group (USA) LLC" & `Publishing Year` >= 2010) |>
select(`Book Name`, `Publishing Year`, `gross sales`) |>
arrange(desc(`gross sales`))
penguin_sales_data
## # A tibble: 23 × 3
## `Book Name` `Publishing Year` `gross sales`
## <chr> <dbl> <dbl>
## 1 Daughter of Smoke & Bone 2011 37952.
## 2 <NA> 2011 7670.
## 3 <NA> 2013 5270.
## 4 Obsidian 2011 5192.
## 5 The Circle 2013 3873.
## 6 Fallen Too Far (Too Far, #1) 2012 2875.
## 7 Wool Omnibus 2012 2250.
## 8 Gabriel's Inferno 2011 1782.
## 9 Hollow City 2014 1643.
## 10 Finale 2012 1517.
## # ℹ 13 more rows
It looks like the book with the top grossing book published by Penguin Group (USA) LLC was released in 2011, which aligns with the spike in the gross sales over time we saw above.
Finally, I want to examine how ratings for this book compare to the ratings for Penguin’s other books. I thought it would be best to examine where a
#filter for penguin books
penguin_data <- book_sales |>
filter(Publisher == "Penguin Group (USA) LLC")
#name of top book
top_sales_book <- "Daughter of Smoke & Bone"
#scatter plot to compare ratings of all penguin books, highlighting their top grossing book
ggplot(penguin_data, aes(x = `Book_average_rating`, y = `gross sales`)) +
geom_point(alpha = 0.7) +
labs(title = "Scatter Plot of Average Book Ratings for Penguin Group (USA) LLC",
x = "Book Average Rating",
y = "Gross Sales") +
geom_point(data = penguin_data %>% filter(`Book Name` == top_sales_book),
aes(x = `Book_average_rating`, y = `gross sales`), color = "red", size = 3) +
geom_text(data = penguin_data %>% filter(`Book Name` == top_sales_book),
aes(x = `Book_average_rating`, y = `gross sales`, label = top_sales_book),
hjust = -0.2, vjust = 0.5, color = "red") +
geom_vline(aes(xintercept = mean(`Book_average_rating`)), color = "black",
size = .5, linetype = "dashed") +
annotate("text", label = "Average", x = 4.15, y = 30000, color = "black" ) +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
The scatter plot revealed that despite topping Penguin Group’s gross sales charts, it was not their highest rated book. Daughter of Smoke & Bone appears to be slightly below average in rating. Since this book was not held in super high regard, it leads me to believe that there must be another reason for this book to be Penguin Group’s top grossing book.