Halo Semuanya, salam kenal! Selamat datang di Rmd saya. Pada Rmd ini saya akan membahas suatu data yang berisikan tentang penjualan buku di salah satu online store yaitu Amazon Store dari tahun 2009 sampai tahun 2019. Dataset ini berisikan tujuh buah kolom yakni
Name : berisikan nama dari buku
Author : berisikan nama author atau penulis dari buku
User rating : berisikan rating yang user berikan
Reviews : berisikan banyaknya user yang mereviews buku
Price : berisikan harga dari buku
Year : berisikan tahun buku tersebut keluar
Genre : berisikan genre dari buku
dari kolom-kolom Rmd ini akan membahas beberapa hal diantaranya :
Bagaimana persebaran dari Genre buku di Amazon Store
Bagaimana persebaran tahun buku-buku dikeluarkan
10 buku apa saja yang paling banyak direviews oleh user
Siapa author yang merilis buku terbanyak
Dari poin 4, buku apa saja yang telah author tersebut rilis dan bagaimana rating dari buku-buku tersebut
Link Dataset (https://www.kaggle.com/datasets/sootersaalu/amazon-top-50-bestselling-books-2009-2019/data)
Sebelum kita melakukan eksplorasi, pertama-tama kita set up library yang akan kita gunakan pada Rmd ini.
library(dplyr)
library(ggplot2)
library(plotly)
library(glue)
library(lubridate)
Selanjutnya kita akan melakukan import/input data kedalam variabel books.
books <- read.csv("datainput/bestsellers with categories.csv")
Kemudian lakukan pemeriksaan kepada kepala dan buntut dari data books.
head(books)
## Name
## 1 10-Day Green Smoothie Cleanse
## 2 11/22/63: A Novel
## 3 12 Rules for Life: An Antidote to Chaos
## 4 1984 (Signet Classics)
## 5 5,000 Awesome Facts (About Everything!) (National Geographic Kids)
## 6 A Dance with Dragons (A Song of Ice and Fire)
## Author User.Rating Reviews Price Year Genre
## 1 JJ Smith 4.7 17350 8 2016 Non Fiction
## 2 Stephen King 4.6 2052 22 2011 Fiction
## 3 Jordan B. Peterson 4.7 18979 15 2018 Non Fiction
## 4 George Orwell 4.7 21424 6 2017 Fiction
## 5 National Geographic Kids 4.8 7665 12 2019 Non Fiction
## 6 George R. R. Martin 4.4 12643 11 2011 Fiction
tail(books)
## Name
## 545 Wonder
## 546 Wrecking Ball (Diary of a Wimpy Kid Book 14)
## 547 You Are a Badass: How to Stop Doubting Your Greatness and Start Living an Awesome Life
## 548 You Are a Badass: How to Stop Doubting Your Greatness and Start Living an Awesome Life
## 549 You Are a Badass: How to Stop Doubting Your Greatness and Start Living an Awesome Life
## 550 You Are a Badass: How to Stop Doubting Your Greatness and Start Living an Awesome Life
## Author User.Rating Reviews Price Year Genre
## 545 R. J. Palacio 4.8 21625 9 2017 Fiction
## 546 Jeff Kinney 4.9 9413 8 2019 Fiction
## 547 Jen Sincero 4.7 14331 8 2016 Non Fiction
## 548 Jen Sincero 4.7 14331 8 2017 Non Fiction
## 549 Jen Sincero 4.7 14331 8 2018 Non Fiction
## 550 Jen Sincero 4.7 14331 8 2019 Non Fiction
Setelah itu kita periksa kembali apakah tipe data masing - masing kolom sudah sesuai, kalau belum maka diubah.
glimpse(books)
## Rows: 550
## Columns: 7
## $ Name <chr> "10-Day Green Smoothie Cleanse", "11/22/63: A Novel", "12 …
## $ Author <chr> "JJ Smith", "Stephen King", "Jordan B. Peterson", "George …
## $ User.Rating <dbl> 4.7, 4.6, 4.7, 4.7, 4.8, 4.4, 4.7, 4.7, 4.7, 4.6, 4.6, 4.6…
## $ Reviews <int> 17350, 2052, 18979, 21424, 7665, 12643, 19735, 19699, 5983…
## $ Price <int> 8, 22, 15, 6, 12, 11, 30, 15, 3, 8, 8, 2, 32, 5, 17, 4, 6,…
## $ Year <int> 2016, 2011, 2018, 2017, 2019, 2011, 2014, 2017, 2018, 2016…
## $ Genre <chr> "Non Fiction", "Fiction", "Non Fiction", "Fiction", "Non F…
Pada hal ini, terdapat kolom Author, dan Genre yang perlu dirubah menjadi tipe data faktor dan juga ubah kolom Year menjadi tipe data Datetime.
books <- books %>% mutate(Author = as.factor(Author), Genre = as.factor(Genre))
books$Year <- year(as.Date(as.character(books$Year),format = "%Y"))
Periksa kembali apakah sudah berubah.
glimpse(books)
## Rows: 550
## Columns: 7
## $ Name <chr> "10-Day Green Smoothie Cleanse", "11/22/63: A Novel", "12 …
## $ Author <fct> JJ Smith, Stephen King, Jordan B. Peterson, George Orwell,…
## $ User.Rating <dbl> 4.7, 4.6, 4.7, 4.7, 4.8, 4.4, 4.7, 4.7, 4.7, 4.6, 4.6, 4.6…
## $ Reviews <int> 17350, 2052, 18979, 21424, 7665, 12643, 19735, 19699, 5983…
## $ Price <int> 8, 22, 15, 6, 12, 11, 30, 15, 3, 8, 8, 2, 32, 5, 17, 4, 6,…
## $ Year <dbl> 2016, 2011, 2018, 2017, 2019, 2011, 2014, 2017, 2018, 2016…
## $ Genre <fct> Non Fiction, Fiction, Non Fiction, Fiction, Non Fiction, F…
Sekarang kita periksa apakah books memiliki data yang terduplikat
sum(duplicated(books))
## [1] 0
periksa juga apakah books memiliki data yang missing.
colSums(is.na(books))
## Name Author User.Rating Reviews Price Year
## 0 0 0 0 0 0
## Genre
## 0
#Data Exploratory Setelah melakukan preprocessing, kita akan melakukan exploratory. Pertama-tama kita ingin mendapatkan gambaran umum atau garis besar dari data kita.
summary(books)
## Name Author User.Rating
## Length:550 Jeff Kinney : 12 Min. :3.300
## Class :character Gary Chapman : 11 1st Qu.:4.500
## Mode :character Rick Riordan : 11 Median :4.700
## Suzanne Collins : 11 Mean :4.618
## American Psychological Association: 10 3rd Qu.:4.800
## Dr. Seuss : 9 Max. :4.900
## (Other) :486
## Reviews Price Year Genre
## Min. : 37 Min. : 0.0 Min. :2009 Fiction :240
## 1st Qu.: 4058 1st Qu.: 7.0 1st Qu.:2011 Non Fiction:310
## Median : 8580 Median : 11.0 Median :2014
## Mean :11953 Mean : 13.1 Mean :2014
## 3rd Qu.:17253 3rd Qu.: 16.0 3rd Qu.:2017
## Max. :87841 Max. :105.0 Max. :2019
##
Berbekal dari summary tersebut kita dapat melakukan exploratory lebih lanjut dan menjawab pertanyaan-pertanyaan yang kita miliki.
table(books$Genre)
##
## Fiction Non Fiction
## 240 310
plot(books$Genre)
# d1 dipakai untuk melakukan visualisasi dengan ggplot
d1 <- books %>% group_by(Genre) %>% summarise(Banyak = n()) %>% ungroup()
d1 <- d1 %>% mutate(label = glue("{Genre}
Jumlah : {Banyak}"))
Jawaban: Data Genre tersebar pada dua kategori yaitu fiction dan non fiction dengan fiction sejumlah 240 dan non fiction 310.
table(books$Year)
##
## 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019
## 50 50 50 50 50 50 50 50 50 50 50
hist(books$Year)
# d2 dipakai untuk melakukan visualisasi dengan ggplot
d2 <- books %>% group_by(Year, Genre) %>% summarise(Banyak = n()) %>% ungroup() %>% mutate(label = glue("{Genre}
Tahun: {Year}
Banyak: {Banyak}"))
Jawaban: Tahun rilis dari buku-buku di amazon store tersebar rata dari tahun 2009 sampai 2019 dengan banyak buku yang rilis per tahunnya adalah sebanyak 50 buku.
# d3 dipakai untuk melakukan visualisasi dengan ggplot
d3 <- books %>% group_by(Name) %>% arrange(-Reviews) %>% head(10) %>% mutate(label = glue("Judul: {Name}
Author: {Author}
Tahun rilis: {Year}
Banyak Review: {Reviews}"))
d3
## # A tibble: 10 × 8
## # Groups: Name [5]
## Name Author User.Rating Reviews Price Year Genre label
## <chr> <fct> <dbl> <int> <int> <dbl> <fct> <glu>
## 1 Where the Crawdads Sing Delia Ow… 4.8 87841 15 2019 Fict… Judu…
## 2 The Girl on the Train Paula Ha… 4.1 79446 18 2015 Fict… Judu…
## 3 The Girl on the Train Paula Ha… 4.1 79446 7 2016 Fict… Judu…
## 4 Becoming Michelle… 4.8 61133 11 2018 Non … Judu…
## 5 Becoming Michelle… 4.8 61133 11 2019 Non … Judu…
## 6 Gone Girl Gillian … 4 57271 10 2012 Fict… Judu…
## 7 Gone Girl Gillian … 4 57271 10 2013 Fict… Judu…
## 8 Gone Girl Gillian … 4 57271 9 2014 Fict… Judu…
## 9 The Fault in Our Stars John Gre… 4.7 50482 13 2012 Fict… Judu…
## 10 The Fault in Our Stars John Gre… 4.7 50482 13 2013 Fict… Judu…
Jawaban: 10 buku yang paling banyak direviews oleh user diantaranya ada “Where the Crawdads Sings” karya Delia Owens, “The Girl on the Trains” karya Paula Hawkins yang keluar pada tahun 2015 dan tahun 2016, “Becoming” karya Michelle Obama, dan seterusnya.
Berikut merupakan visualisasi dengan ggplot untuk menjawab dari pertanyaan-pertanyaan diatas.
plot1 <- ggplot(d1, aes(x= Genre, y = Banyak, fill = Genre, text = label)) + geom_bar(stat="identity") + scale_fill_manual(values=c("#000000","#ff9900" )) +
labs(title = "Persebaran Genre buku pada Amazon Store",
x = "Genre",
y = NULL) +
theme_light()
ggplotly(plot1 , tooltip = "text") %>%
layout(legend = list(orientation = "h", x = 0.3, y = -0.2))
plot2 <- ggplot(d2, aes(x= Year, y=Banyak, fill = Genre, text = label)) +geom_bar(stat = "Identity", position = "dodge", color = "#000000") + scale_fill_manual(values=c("#f2f2f2","#ff9900" )) + labs(title = "Persebaran Tahun Keluar",
x = "Tahun",
y = NULL)+ theme_light()
ggplotly(plot2, tooltip = "text") %>%
layout(legend = list(orientation = "h", x = 0.3, y = -0.2))
plot3 <- ggplot(d3, aes(x = Reviews , y= reorder(1:nrow(d3), Reviews) , fill = Name, text = label)) + geom_bar(stat = "Identity", color = "#000000") +
scale_fill_manual(values=c( "#f2f2f2", "#2DBFF8", "#08AAE3", "#E4C083", "#CEA968" )) + labs(title = "10 Buku Paling Direview",
x = "Reviewers",
y = NULL) +
theme_minimal() +theme(legend.position = "none") + scale_y_discrete(labels=d3$Name, breaks=rev(1:nrow(d3)), limits=rev(1:nrow(d3)),) + scale_x_continuous(labels = scales::comma)
ggplotly(plot3, tooltip = "text")
plot4 <- ggplot(d4, aes(x= Banyak, y = reorder(Author,Banyak), fill = Author, text = label)) + geom_bar(stat = "Identity", color = "#000000") +
scale_fill_manual(values=c( "#2DBFF8" ,"#146eb4", "#ff9900", "#232f3e", "#f2f2f2" )) + labs(title = "Penulis dengan Rilis Buku Terbanyak",
x = "Banyak Buku",
y = NULL) +
theme_minimal() + theme(legend.position = "none")
ggplotly(plot4, tooltip = "text")
plot5 <- ggplot(d5, aes(x= User.Rating, y = reorder(Name,User.Rating), fill = Name, text = label)) + geom_bar(stat = "Identity", color = "#000000") +
theme_minimal() + theme(legend.position = "none") +
scale_fill_manual(values = c("#E35335","#7DF9FF", "#228B22", "#FFAA33", "#FDDA0D" , "#FF2400", "#36454F", "#0047AB", "#800080", "#B4C424", "#BF40BF", "#818589" )) +
labs(title = "Rating Buku Karangan Jeff Kinney",
x = "Rating",y = NULL)
ggplotly(plot5, tooltip = "text")