library(ggplot2)
library(dslabs)
#Load the diamonds dataset
data("diamonds")Week 8 Assignment
#Intro This project will look at a dataset about diamonds. I am using the diamonds dataset from dslabs that provides details about diamonds such as their carat weightm cut quality, and price. My goal is to be able to visualize how the price of a diamond is influenced by its carat weight and cut quality.
#Libraries
#Plotting the data to visualize I will start by making a scatter plot to show the reationship between diamond price carat and cut quality.
#Define the base plot
p <- ggplot(diamonds, aes(x = carat, y = price, color = cut)) +
#Adding the data points
geom_point(alpha = 0.6)+
#Add labels and titles
labs(
title = "Relationship of Diamond Price, Carat, and Cut",
x = "Carat Weight",
y = "Price in USD",
color = "Cut Quality"
)+
#Theme
theme_minimal() +
#Legend
theme(legend.position = "top")
#Create the plot
print(p)This graph shows the relationship of the size of a diamond (known as a carat) and its price. Each point on the graph is a diamond. The color of the point shows the quality of the diamonds cut, like “Excelent” or “Good”. The graph is designed to be easy to read.
The graph tells me that bigger diamonds are generally a lot more expensive, and the quality of the cut seems to have an impact on the price.