This markdown document is created as part of the Week 3 course project on Coursera’s Developing Data Products. This will implement the use of the R package plotly to display a plot of popular books on Goodreads based on average user ratings and genre.
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(ggplot2)
df <- read.csv("books.csv")
df$genre <- as.factor(df$genre)
# Plot ratings against genre
a <- ggplot(df, aes(title, rating,
col = genre)) +
geom_point(aes(size = genre), alpha = 0.6) +
theme(axis.text.x = element_blank(), legend.position = "none") +
labs(title = "Ratings of each book", x = "Books", y = "Ratings",
subtitle = "Which genre has the book with the highest rating?",
col = "Genre", size = "Genre")
ggplotly(a)
## Warning: Using size for a discrete variable is not advised.