Diamonds dataset from R

Author

Mckayla Blankenberg

Published

April 5, 2026

Introduction

Our main focus in the diamonds dataset from R. We will be looking into more details surrounding the coding as well as figures we conclude on from the dataset

Running Code

We will need to insert the following libraries that we will be using throughout this section:

library(tidyverse)
library(ggplot2)
library(dplyr)
library(gt)
Warning: package 'gt' was built under R version 4.5.3

Dataset

data(diamonds)
gt(head(diamonds))
carat cut color clarity depth table price x y z
0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43
0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31
0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31
0.29 Premium I VS2 62.4 58 334 4.20 4.23 2.63
0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75
0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48

Code

ggplot(diamonds, aes(x=carat,
                     y = price,
                     color=color))+
  geom_point()+
  geom_smooth()+
  labs(title='diamond prices based on carat')

Other figure(s)

Bar graph showing the various cuts of diamonds

Boxplot showing the various cuts of diamonds

Conclusion

We have analysed the different types of diamonds based on the given dataset “diamonds”.

Also note:

facet_wrap was used to show the cuts of the diamonds and their prices based on the different colors. We can use this figure to analyse the differences in colors between the diamonds. Facet wrap is 1 dimensional (1D) as a single variable is used to create subplots.