Q0: Finish all Lab Exercises

Create a density plot of interest_rate in loans data with

loans <- dplyr::select(loans_full_schema, loan_amount, interest_rate, term, 
         grade, state, annual_income, homeownership, debt_to_income)
ggplot(loans, aes(x = interest_rate)) +
         geom_density(color = "blue", fill = "green", linetype = "dashed", linewidth = 1.5)

Do a simple graph ggplot(mpg) + geom_point(aes(x = cty, y = hwy)), make the following customization of your graph:

  1. Make a title of “Fuel Economy Data”
  2. Make your x label of “miles per gallon in city”, and a y label of “miles per gallon in highway”.
  3. Make your title 2 times larger and in color blue
  4. Make your labels in x and y 1.5 times larger
  5. Change the aspect ratio of your graph to be 1 to make your graph square. Find how to do this by yourself with the assistance of help documentation.
ggplot(data = 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(color = "blue", size = rel(2)), axis.title = element_text(size = rel(1.5)), plot.margin = margin(1,1,1,1,unit = "cm") ) +
#Change the aspect ratio of your graph to be 1
coord_fixed(ratio = 1)

Q1 : Create a graph based on the diamonds data set with the following requirements:

Anwser:

ggplot(data = diamonds) +
  geom_point(mapping = aes(x = carat, y = price, color = clarity)) +
  scale_y_continuous(name = "price in US dollars ", labels = scales::dollar) + scale_x_continuous(name = "weight of the diamond") +
  facet_grid(cut~color) +

#To be a grid of scatter plots
theme_linedraw()

Q: Do you think the plot is informative? Provide your opinion.

Anwser:

I think this plot is too informative, you can see 5 variables according this plot