Primeira Visualização

Histograma de Preços

ggplot(diamonds, aes(x = price)) +
  geom_histogram(bins = 30, fill = "steelblue", color = "black") +
  labs(title = "Distribuição de Preços dos Diamantes",
       x = "Preço (USD)",
       y = "Frequência") +
  theme_minimal()

Relação entre Variáveis

ggplot(diamonds, aes(x = carat, y = price)) +
  geom_point(alpha = 0.3, color = "darkblue") +
  geom_smooth(method = "lm", color = "red") +
  labs(title = "Relação entre Quilate e Preço",
       x = "Quilate",
       y = "Preço (USD)") +
  theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'

Análise por Categorias

Preço por Corte

ggplot(diamonds, aes(x = cut, y = price, fill = cut)) +
  geom_boxplot() +
  labs(title = "Distribuição de Preços por Tipo de Corte",
       x = "Corte",
       y = "Preço (USD)") +
  theme_minimal() +
  theme(legend.position = "none")

Cálculo de Medidas

Medidas

diamonds %>%
  group_by(cut, color) %>%
  summarise(
    media_preco = mean(price),
    mediana_preco = median(price),
    n = n(),
    .groups = 'drop'
  ) %>%
  head(10) %>%
  knitr::kable(digits = 2)
cut color media_preco mediana_preco n
Fair D 4291.06 3730.0 163
Fair E 3682.31 2956.0 224
Fair F 3827.00 3035.0 312
Fair G 4239.25 3057.0 314
Fair H 5135.68 3816.0 303
Fair I 4685.45 3246.0 175
Fair J 4975.66 3302.0 119
Good D 3405.38 2728.5 662
Good E 3423.64 2420.0 933
Good F 3495.75 2647.0 909

Conclusão

## Análise concluída com 53940 observações e 10 variáveis.
knitr::include_graphics("https://br.freepik.com/fotos-vetores-gratis/figura-geometrica")