Create a density plot of interest_rate in loans data with:
ggplot(data = loans, mapping = aes(x = interest_rate)) +
geom_density(color = "blue", fill = "green", linetype = "dashed", linewidth = 1.5) +
labs(x = "Interest Rate (%)",
y = "Density",
title = "The Interest Rate from Lending Club Data") +
theme(plot.title = element_text(hjust = 0.5))
Do a simple graph ggplot(mpg) + geom_point(aes(x = cty, y = hwy)), make the following customization of your graph:
ggplot(data = mpg) +
geom_point(mapping = aes (x = cty, y = hwy), color = "orange2", size = 3) +
labs(title = "Fuel Economy Data",
x = "miles per gallon in city",
y = "miles per gallon in highway") +
theme(plot.title = element_text(hjust = 0.5, size = rel(2), color = "blue"),
axis.title = element_text(hjust = 0.5, size = rel(1.5)))
-A grid of scatter plots with x being carat and y being price.
-In each plot, use different colors for different clarity quality.
-For the grid of subplots, the x-axis should refer to different cut
quality, and the y-axis referring to different diamond color.
-The scale of y-axis should be in the format like $5,000 etc.
ggplot(data = diamonds) +
geom_point(mapping = aes(x = carat, y = price, color = clarity)) +
facet_grid(color ~ cut) +
xlim(0, 5) + ylim(0, 20000) +
labs(title = "Diamond Quality Data by Its Clarity and Cut",
x = "Weight of the Diamonds (Carat)",
y = "Price of the Diamonds (USD)") +
theme(plot.title = element_text(hjust = 0.5, size = rel(2.3), margin = margin(20, 25, 20, 20), color = "blue4"),
axis.title = element_text(size = rel(1.5), color = "green4"),
axis.title.x = element_text(size = rel(1.1), margin = margin(15, 5, 5, 5)),
axis.title.y = element_text(size = rel(1.1), margin = margin(5, 10, 15, 5)),
axis.text = element_text(size = rel(1.2), color = "green4")) +
scale_y_continuous(labels = scales::dollar)
Do you think the plot is informative? Provide your
opinion.
Answer: Yes, this provides valuable information
about the overall distribution of diamond quality and price ranges for
different grades. Additionally, if you have a specific diamond and want
to assess whether you purchased it at a fair price, this plot can be
useful, as it allows for quick analysis.
On the other hand, it may feel overwhelming to interpret at a glance
for those looking to study the relationships between variables. To make
the data more accessible, I would present it through multiple simpler
plots rather than condensing everything into a single table.
Submit your answer in a single pdf or html knitted from a
R markdown file. Submit your R markdown file as
well.