Este relatório realiza uma análise exploratória da base
P2-Mispriced-Diamonds.csv, utilizando gráficos de dispersão
e categorização por clarity. O arquivo pode ser baixado
diretamente do Google Drive ou acessado via unidade mapeada no
Windows.
Origem: Os dados utilizados neste projeto foram obtidos do conjunto Diamonds disponível no Kaggle: Conjunto de dados Diamonds no Kaggle.
Status: Público / Fictício
Este relatório utiliza a base
P2-Mispriced-Diamonds.csv.
Para reproduzir a análise, baixe o arquivo aqui:
🔗 [Download do CSV] Baixar a base de dados.
# Instalar e carregar pacotes necessários
pkgs <- c("ggplot2", "data.table", "googledrive")
to_install <- pkgs[!pkgs %in% installed.packages()[, "Package"]]
if (length(to_install)) install.packages(to_install)
invisible(lapply(pkgs, library, character.only = TRUE))
library(googledrive)
# Verifica se já existe um token ativo
if (is.null(drive_token())) {
message("Nenhum token encontrado. Autenticando no Google Drive...")
drive_auth(scopes = "https://www.googleapis.com/auth/drive")
} else {
message("Já autenticado no Google Drive. Seguindo normalmente...")
}
library(data.table)
# Caminho direto para o arquivo no Google Drive mapeado
# Você lê direto da pasta do google drive, via o teu explorador de arquivos (no meu caso: windows)
# Baixar arquivo devido extensão ".csv" (Se google sheet, já conecta "direto" no link).
mydata <- "G:/Meu Drive/R/Analise-Preco-Diamantes/Pasta-Arquivo-Projeto/P2-Mispriced-Diamonds.csv"
# Carregar os dados
mydata <- fread("P2-Mispriced-Diamonds.csv")
# Inspeção
mydata
## carat clarity price
## <num> <char> <int>
## 1: 0.23 SI2 326
## 2: 0.21 SI1 326
## 3: 0.23 VS1 327
## 4: 0.29 VS2 334
## 5: 0.31 SI2 335
## ---
## 53935: 0.72 SI1 2757
## 53936: 0.72 SI1 2757
## 53937: 0.72 SI1 2757
## 53938: 0.70 SI1 2757
## 53939: 0.86 SI2 2757
str(mydata)
## Classes 'data.table' and 'data.frame': 53939 obs. of 3 variables:
## $ carat : num 0.23 0.21 0.23 0.29 0.31 0.24 0.24 0.26 0.22 0.23 ...
## $ clarity: chr "SI2" "SI1" "VS1" "VS2" ...
## $ price : int 326 326 327 334 335 336 336 337 337 338 ...
## - attr(*, ".internal.selfref")=<externalptr>
dim(mydata)
## [1] 53939 3
summary(mydata)
## carat clarity price
## Min. :0.2000 Length:53939 Min. : 326
## 1st Qu.:0.4000 Class :character 1st Qu.: 950
## Median :0.7000 Mode :character Median : 2401
## Mean :0.7979 Mean : 3933
## 3rd Qu.:1.0400 3rd Qu.: 5324
## Max. :5.0100 Max. :18823
table(mydata$clarity)
##
## I1 IF SI1 SI2 VS1 VS2 VVS1 VVS2
## 741 1790 13065 9193 8171 12258 3655 5066
# Remover o arquivo se quiser limpar o diretório
# file.remove("P2-Mispriced-Diamonds.csv")
ggplot(data = mydata, aes(x = carat, y = price)) +
geom_point() +
labs(title = "Dispersão: Carat vs Preço", x = "Carat", y = "Preço")
ggplot(data = mydata, aes(x = carat, y = price, colour = clarity)) +
geom_point() +
labs(title = "Dispersão por Clarity", x = "Carat", y = "Preço", colour = "Clarity")
ggplot(data = mydata[mydata$carat < 2.5, ],
aes(x = carat, y = price, colour = clarity)) +
geom_point(alpha = 0.1) +
geom_smooth() +
labs(title = "Dispersão filtrada (carat < 2.5)", x = "Carat", y = "Preço")
OS documentos deste relatório está disponível em:
Relatório no GitHub Pages.
carat e price é positiva e
clara nos gráficos.clarity adiciona uma dimensão categórica
importante.carat < 2.5 ajuda a reduzir o
impacto de outliers.geom_smooth() revela tendências gerais
entre peso e preço.