Import dataset

library(readr)
bestsellers <- read_csv("bestsellers with categories.csv")
## Rows: 550 Columns: 7
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (3): Name, Author, Genre
## dbl (4): User Rating, Reviews, Price, Year
## 
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.


Understand the dataset

class(bestsellers)
## [1] "spec_tbl_df" "tbl_df"      "tbl"         "data.frame"
dim(bestsellers)
## [1] 550   7
names(bestsellers)
## [1] "Name"        "Author"      "User Rating" "Reviews"     "Price"      
## [6] "Year"        "Genre"


Most highly rated book each year

books2009 <- subset(bestsellers, Year == 2009)
max2009 <- books2009[which.max(books2009$"User Rating"),]

books2010 <- subset(bestsellers, Year == 2010)
max2010 <- books2010[which.max(books2010$"User Rating"),]

books2011 <- subset(bestsellers, Year == 2011)
max2011 <- books2011[which.max(books2011$"User Rating"),]

books2012 <- subset(bestsellers, Year == 2012)
max2012 <- books2012[which.max(books2012$"User Rating"),]

books2013 <- subset(bestsellers, Year == 2013)
max2013 <- books2013[which.max(books2013$"User Rating"),]

books2014 <- subset(bestsellers, Year == 2014)
max2014 <- books2014[which.max(books2014$"User Rating"),]

books2015 <- subset(bestsellers, Year == 2015)
max2015 <- books2015[which.max(books2015$"User Rating"),]

books2016 <- subset(bestsellers, Year == 2016)
max2016 <- books2016[which.max(books2016$"User Rating"),]

books2017 <- subset(bestsellers, Year == 2017)
max2017 <- books2017[which.max(books2017$"User Rating"),]

books2018 <- subset(bestsellers, Year == 2018)
max2018 <- books2018[which.max(books2018$"User Rating"),]

books2019 <- subset(bestsellers, Year == 2019)
max2019 <- books2019[which.max(books2019$"User Rating"),]

maxbyyear <- rbind(max2009,max2010,max2011,max2012,max2013,max2014,max2015,max2016,max2017,max2018,max2019)

library(knitr)
knitr::kable(maxbyyear, align = "llrrrrr", caption = "Amazon's Top Rated Book By Year")
Amazon’s Top Rated Book By Year
Name Author User Rating Reviews Price Year Genre
Diary of a Wimpy Kid: The Last Straw (Book 3) Jeff Kinney 4.8 3837 15 2009 Fiction
Percy Jackson and the Olympians Paperback Boxed Set (Books 1-3) Rick Riordan 4.8 548 2 2010 Fiction
Jesus Calling: Enjoying Peace in His Presence (with Scripture References) Sarah Young 4.9 19576 8 2011 Non Fiction
Goodnight, Goodnight Construction Site (Hardcover Books for Toddlers, Preschool Books for Kids) Sherri Duskey Rinker 4.9 7038 7 2012 Fiction
Goodnight, Goodnight Construction Site (Hardcover Books for Toddlers, Preschool Books for Kids) Sherri Duskey Rinker 4.9 7038 7 2013 Fiction
Jesus Calling: Enjoying Peace in His Presence (with Scripture References) Sarah Young 4.9 19576 8 2014 Non Fiction
Humans of New York : Stories Brandon Stanton 4.9 2812 17 2015 Non Fiction
Hamilton: The Revolution Lin-Manuel Miranda 4.9 5867 54 2016 Non Fiction
Brown Bear, Brown Bear, What Do You See? Bill Martin Jr. 4.9 14344 5 2017 Fiction
Dog Man and Cat Kid: From the Creator of Captain Underpants (Dog Man #4) Dav Pilkey 4.9 5062 6 2018 Fiction
Brown Bear, Brown Bear, What Do You See? Bill Martin Jr. 4.9 14344 5 2019 Fiction


Mean price of the top 50 bestselling books from 2009-2019

paste("The average price of Amazon's top 50 bestselling books from 2009-2019 is $", mean(bestsellers$Price),".")
## [1] "The average price of Amazon's top 50 bestselling books from 2009-2019 is $ 13.1 ."


Median price of the top 50 bestselling books, 2009-2019

paste("The median price of Amazon's top 50 bestselling books from 2009-2019 is $", median(bestsellers$Price),".")
## [1] "The median price of Amazon's top 50 bestselling books from 2009-2019 is $ 11 ."


Notable books

# Most reviewed
paste("The most reviewed book was '",bestsellers[which.max(bestsellers$Reviews),"Name"],"' by ",bestsellers[which.max(bestsellers$Reviews),"Author"]," in ",bestsellers[which.max(bestsellers$Reviews),"Year"]," with ",max(bestsellers$Reviews)," reviews.")
## [1] "The most reviewed book was ' Where the Crawdads Sing ' by  Delia Owens  in  2019  with  87841  reviews."
# Most expensive
paste("The most expensive book was '",bestsellers[which.max(bestsellers$Price),"Name"],"' by ",bestsellers[which.max(bestsellers$Price),"Author"]," in ",bestsellers[which.max(bestsellers$Price), "Year"], " at $", max(bestsellers$Price),".")
## [1] "The most expensive book was ' Diagnostic and Statistical Manual of Mental Disorders, 5th Edition: DSM-5 ' by  American Psychiatric Association  in  2013  at $ 105 ."