Este projeto analisa os 50 livros mais vendidos na Amazon entre 2009 e 2019. Os dados foram obtidos da base pública disponível em Kaggle.
Objetivo: Explorar padrões de vendas, autores mais populares e tendências ao longo dos anos.
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readr)
library(ggplot2)
descrição: é necessário instalar e carregar os pacotes que serão utilizados na análise antes de começar.
bestsellers <- read_csv("C:/Users/emily/projetosPessoais/R/amazon_bestsellers.csv")
## Rows: 550 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): Name, Author, Genre
## dbl (4): User Rating, Reviews, Price, Year
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(bestsellers)
## # A tibble: 6 × 7
## Name Author `User Rating` Reviews Price Year Genre
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <chr>
## 1 10-Day Green Smoothie Cleanse JJ Sm… 4.7 17350 8 2016 Non …
## 2 11/22/63: A Novel Steph… 4.6 2052 22 2011 Fict…
## 3 12 Rules for Life: An Antidote… Jorda… 4.7 18979 15 2018 Non …
## 4 1984 (Signet Classics) Georg… 4.7 21424 6 2017 Fict…
## 5 5,000 Awesome Facts (About Eve… Natio… 4.8 7665 12 2019 Non …
## 6 A Dance with Dragons (A Song o… Georg… 4.4 12643 11 2011 Fict…
Descrição: Aqui visualizamos as primeiras linhas do dataset para entender a estrutura dos dados.
glimpse(bestsellers)
## Rows: 550
## Columns: 7
## $ Name <chr> "10-Day Green Smoothie Cleanse", "11/22/63: A Novel", "1…
## $ Author <chr> "JJ Smith", "Stephen King", "Jordan B. Peterson", "Georg…
## $ `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…
## $ Reviews <dbl> 17350, 2052, 18979, 21424, 7665, 12643, 19735, 19699, 59…
## $ Price <dbl> 8, 22, 15, 6, 12, 11, 30, 15, 3, 8, 8, 2, 32, 5, 17, 4, …
## $ Year <dbl> 2016, 2011, 2018, 2017, 2019, 2011, 2014, 2017, 2018, 20…
## $ Genre <chr> "Non Fiction", "Fiction", "Non Fiction", "Fiction", "Non…
dim(bestsellers)
## [1] 550 7
colnames(bestsellers)
## [1] "Name" "Author" "User Rating" "Reviews" "Price"
## [6] "Year" "Genre"
Descrição: * glimpse() mostra os tipos de cada coluna. * dim() informa linhas e colunas. * colnames() lista os nomes das variáveis.
bestsellers %>%
count(Author, sort = TRUE) %>%
slice_max(n, n=10, with_ties = FALSE)
## # A tibble: 10 × 2
## Author n
## <chr> <int>
## 1 Jeff Kinney 12
## 2 Gary Chapman 11
## 3 Rick Riordan 11
## 4 Suzanne Collins 11
## 5 American Psychological Association 10
## 6 Dr. Seuss 9
## 7 Gallup 9
## 8 Rob Elliott 8
## 9 Bill O'Reilly 7
## 10 Dav Pilkey 7
Descrição: Esta tabela mostra quantos livros cada autor possui no Top 50.
bestsellers %>%
count(Author, sort = TRUE) %>%
slice_max(n, n = 10, with_ties = FALSE) %>%
ggplot(aes(x = reorder(Author, n), y = n)) +
geom_col(fill = "steelblue") +
coord_flip() +
labs(
title = "Autores mais recorrentes nos Bestsellers (2009-2019)",
x = "Autor",
y = "Quantidade de livros no Top 50"
)
bestsellers %>%
count(Genre)
## # A tibble: 2 × 2
## Genre n
## <chr> <int>
## 1 Fiction 240
## 2 Non Fiction 310
bestsellers %>%
count(Genre, sort = TRUE) %>%
slice_max(order_by = n, n = 5, with_ties = FALSE) %>%
ggplot(aes(x = Genre, y = n, fill = Genre)) +
geom_col() +
labs(
title = "Gêneros mais vendidos (2009-2019)",
x = "Gênero",
y = "Quantidade"
)
Dataset Kaggle - Amazon Top 50 Bestselling Books 2009-2019 link