library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.4.3
## 
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
data(diamonds)


ggplot(data = diamonds, aes(x = carat, y = price)) +
  geom_point(color = "blue")

ggplot(data = diamonds, aes(x = carat, y = price, color = cut)) +
  geom_point(size = 1.5) +
  ggtitle("Relación entre Precio y Quilates según el Corte")

ggplot(data = diamonds, aes(x = clarity, y = price)) +
  geom_boxplot(fill = "orange") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

ggplot(data = diamonds, aes(x = price)) +
  geom_histogram(bins = 30, fill = "green", color = "black")

diamonds_avg <- diamonds %>%
  group_by(carat) %>%
  summarise(mean_price = mean(price))

ggplot(data = diamonds_avg, aes(x = carat, y = mean_price)) +
  geom_line()