# Load packages
library(tidyverse)
library(ggplot2)
library(dplyr)
library(broom)

# Read in the dataset (from the url or directly from the file in your folder)
books = read.csv("http://www.maths.usyd.edu.au/u/UG/JM/DATA1001/r/current/projects/2022data/books.csv")
disease = read.csv("http://www.maths.usyd.edu.au/u/UG/JM/DATA1001/r/current/projects/2022data/disease.csv")
avocado = read.csv("http://www.maths.usyd.edu.au/u/UG/JM/DATA1001/r/current/projects/2022data/avocado.csv")

Recommendation

Client: Dymocks (https://www.dymocks.com.au/)
Dymocks, an Australian-founded bookstore chain request for the data analysis to guide the selection of books that will increase their sales. Based on the evidence presented in this report, Dymocks should take into account the number of pages when selecting books to sell, since this greatly impacts the books’ popularity.

Evidence

Positive Relationship Between Book Length and Rating

books$average_rating <- as.numeric(books$average_rating)
books$num_pages <- as.numeric(books$num_pages)
books <- na.omit(books)
books <- books[order(books$ratings_count),]

plot1 <- ggplot(books, aes(x = num_pages, y = average_rating, color = ratings_count)) +
  geom_point(size=1.2)+
  geom_smooth(formula = y ~ x, method='lm',color="#003399")+
  scale_colour_gradient2(low = "#F9A825",
    midpoint = 1.3e+6,
    mid = "white",
    high = "#4C01B2") +
  guides(color = guide_colorbar(title = "Number of Ratings"))+
  theme(panel.background = element_rect(fill = '#F7F7F7'))

plot1 <- plot1 + ggtitle("Relationship Between Books's Average Rating and Number of Pages") +
  xlab("Number of Pages") + ylab("Average Rating")

plot1 <- plot1 + theme(plot.title=element_text(size=15))

plot1

Figure 1. Plot of the relationship between average rating of books and the number of pages, with a linear regression line to show the relationship and colored by the number of ratings for each data point.

Based on Figure 1, there is a positive correlation between the average rating and the number of pages in a book, meaning that a book with more pages is more likely to receive higher ratings. As a result of their previous positive experience, they have a greater chance of recommend it to others or purchase another book from Dymocks in the future. On the other hand, the number of ratings, represented by colors on the plot, did not seem to correlate with average rating. In other words, even if a book receives more ratings, it doesn’t necessarily mean that it is popular or well-liked by the readers.

However, while a positive linear regression line was visible in Figure 1, there was no indication of how many readers rated each book, so a data point may be assigned a high or low rating only because of a few readers’ oppinions and the linear regression might be slightly affected by this.

Books In Different Rating Ranges Are Differ In Average Book Lengths

books$Rating_Group <- "high"

books <- within(books, Rating_Group[average_rating < 3.5] <- 'median')
books <- within(books, Rating_Group[average_rating < 2] <- 'low')

books$Rating_Group <- factor(books$Rating_Group , levels=c("low", "median", "high"))

plot3 <- ggplot(books, aes(x=num_pages, y = Rating_Group, fill = Rating_Group)) + 
  geom_boxplot()

plot3 <- plot3 +
  theme(panel.background = element_rect(fill = '#F7F7F7')) +
  scale_fill_manual(values = c("high" = "#A988D6","median" = "white", "low" = "#F1BA61"))

plot3 <- plot3 +
  xlab("Number of Pages") + ylab("Rating Group") 

plot3

Figure 3. Boxplot of number of pages books’ have group by high (above 3.5), median (3.5 - 2), and low (below 2) average rating.

The high-rated books, as shown in Figure 3, have more pages on average. Despite some outliers in the graph, high-rated books have a higher median number of pages than median-rated books, and median-rated books also have a higher median number of pages than low-rated books. Supporting the statement that a book with more pages will be more likely to be loved by its customers.

Conclusion

In sum, based on the above evidences, it appears that an increase in the number of pages in a book did affect the rating positively. It is important that Dymocks consider the number of pages in a book when choosing which books to sell since customers with positive shopping and reading experiences are more likely to purchase books or other products from Dymocks.

Acknowledgments

Loiselle, M. (2022, April 26). 3 important statistics that show how reviews influence consumers. Dixa. Retrieved October 22, 2022, from https://www.dixa.com/blog/3-important-statistics-that-show-how-reviews-influence-consumers/