library(tidyverse)
library(openintro)
loans <- select(loans_full_schema, loan_amount, interest_rate, term,
grade, state, annual_income, homeownership, debt_to_income)
Create a density plot of interest_rate in loans data with
ggplot(loans, aes(x = interest_rate)) +
geom_density(linewidth = 1.5, fill = 'green', linetype = 'dashed', color = 'blue')
Do a simple graph ggplot(mpg) + geom_point(aes(x = cty, y = hwy)), make the following customization of your graph:
ggplot(mpg) +
geom_point(aes(x = cty, y = hwy)) +
labs(title = "Fuel Economy Data",
x = "Miles per gallon in city",
y = "Miles per gallon in highway") +
theme(plot.title = element_text(size = rel(2), colour = "blue"),
axis.title = element_text(size = rel(1.5)),
aspect.ratio = 1)
ggplot(diamonds) +
geom_point(aes(x = carat, y = price, color = clarity)) +
facet_grid(cut ~ color) +
scale_y_continuous(labels = scales::dollar) +
labs(title = "Carat vs Price",
x = "Carat",
y = "Price (USD)") +
theme(plot.title = element_text(size = rel(2), colour = "blue"),
axis.title = element_text(size = rel(1.5)),
aspect.ratio = 1)
Answer: I think the plot is quite informative since it shows the trend: as carat increases, price also increases. But the issue is it has too many points so it is kinda hard to read.