Este relatório apresenta uma análise exploratória dos dados de
corridas e faturamento do Serviço Executivo RJ,
utilizando a base Transporte_Executivo_RJ.xlsx (aba
Corridas_RJ). O objetivo é preparar os dados, calcular
estatísticas com dplyr, gerar gráficos com
ggplot2 e simular o cálculo salarial dos vendedores
(motoristas).
library(readxl)
library(dplyr)
library(lubridate)
library(ggplot2)
library(knitr)
dados_brutos <- read_excel("Transporte_Executivo_RJ.xlsx", sheet = "Corridas_RJ")
dados <- dados_brutos %>%
transmute(
vendedor = as.factor(motorista),
dias = as.Date(data),
venda_diaria = as.numeric(valor_corrida),
ano = year(as.Date(data)),
mes = month(as.Date(data)),
cliente = as.factor(cliente),
origem = as.factor(origem),
destino_turistico = as.factor(destino_turistico),
tipo_veiculo = as.factor(tipo_veiculo),
distancia_km = as.numeric(distancia_km),
passageiros = as.numeric(passageiros)
) %>%
filter(!is.na(venda_diaria))
str(dados)
## tibble [300 × 11] (S3: tbl_df/tbl/data.frame)
## $ vendedor : Factor w/ 6 levels "M001","M002",..: 2 2 6 5 2 2 5 4 4 5 ...
## $ dias : Date[1:300], format: "2025-12-17" "2025-10-01" ...
## $ venda_diaria : num [1:300] 339 202 301 248 233 ...
## $ ano : num [1:300] 2025 2025 2025 2025 2025 ...
## $ mes : num [1:300] 12 10 3 9 6 11 9 8 1 11 ...
## $ cliente : Factor w/ 10 levels "Ana Souza","Camila Nunes",..: 8 3 8 8 2 8 9 5 2 6 ...
## $ origem : Factor w/ 6 levels "Aeroporto Galeão",..: 6 4 4 5 2 2 5 5 3 2 ...
## $ destino_turistico: Factor w/ 10 levels "AquaRio","Cristo Redentor",..: 1 3 6 5 4 7 2 10 8 3 ...
## $ tipo_veiculo : Factor w/ 3 levels "Sedan Executivo",..: 2 3 1 3 1 1 1 1 3 2 ...
## $ distancia_km : num [1:300] 37 14 27 16 17 19 30 17 15 9 ...
## $ passageiros : num [1:300] 8 6 8 6 7 2 1 1 7 1 ...
head(dados)
## # A tibble: 6 × 11
## vendedor dias venda_diaria ano mes cliente origem destino_turistico
## <fct> <date> <dbl> <dbl> <dbl> <fct> <fct> <fct>
## 1 M002 2025-12-17 339. 2025 12 Maria C… Santo… AquaRio
## 2 M002 2025-10-01 202. 2025 10 Carlos … Ipane… Escadaria Selarón
## 3 M006 2025-03-18 301. 2025 3 Maria C… Ipane… Maracanã
## 4 M005 2025-09-18 248. 2025 9 Maria C… Leblon Jardim Botânico
## 5 M002 2025-06-04 233. 2025 6 Camila … Barra… Forte de Copacab…
## 6 M002 2025-11-25 210. 2025 11 Maria C… Barra… Museu do Amanhã
## # ℹ 3 more variables: tipo_veiculo <fct>, distancia_km <dbl>, passageiros <dbl>
summary(dados)
## vendedor dias venda_diaria ano mes
## M001:62 Min. :2025-01-01 Min. : 97.86 Min. :2025 Min. : 1.00
## M002:51 1st Qu.:2025-04-11 1st Qu.:188.08 1st Qu.:2025 1st Qu.: 4.00
## M003:45 Median :2025-07-16 Median :242.19 Median :2025 Median : 7.00
## M004:57 Mean :2025-07-06 Mean :241.15 Mean :2025 Mean : 6.65
## M005:53 3rd Qu.:2025-09-25 3rd Qu.:292.17 3rd Qu.:2025 3rd Qu.: 9.00
## M006:32 Max. :2025-12-30 Max. :398.38 Max. :2025 Max. :12.00
##
## cliente origem destino_turistico
## Ana Souza : 37 Aeroporto Galeão:40 Escadaria Selarón :44
## João Pedro : 36 Barra da Tijuca :49 AquaRio :34
## Maria Costa : 34 Copacabana :50 Cristo Redentor :34
## Lucas Santos : 33 Ipanema :44 Maracanã :34
## Camila Nunes : 29 Leblon :73 Forte de Copacabana:30
## Fernanda Lima: 29 Santos Dumont :44 Pão de Açúcar :29
## (Other) :102 (Other) :95
## tipo_veiculo distancia_km passageiros
## Sedan Executivo: 96 Min. : 5.00 Min. :1.000
## SUV Executivo : 96 1st Qu.:14.00 1st Qu.:3.000
## Van Executiva :108 Median :22.00 Median :5.000
## Mean :22.69 Mean :4.517
## 3rd Qu.:31.00 3rd Qu.:6.000
## Max. :40.00 Max. :8.000
##
resumo_vendedor <- dados %>%
group_by(vendedor) %>%
summarise(
venda_total = sum(venda_diaria, na.rm = TRUE),
media_diaria = mean(venda_diaria, na.rm = TRUE),
mediana_diaria = median(venda_diaria, na.rm = TRUE),
desvio_padrao = sd(venda_diaria, na.rm = TRUE),
total_registros = n(),
.groups = "drop"
) %>%
arrange(desc(venda_total))
kable(resumo_vendedor, digits = 2, caption = "Estatísticas por vendedor (ordem decrescente)")
| vendedor | venda_total | media_diaria | mediana_diaria | desvio_padrao | total_registros |
|---|---|---|---|---|---|
| M001 | 15587.70 | 251.41 | 257.55 | 60.14 | 62 |
| M004 | 14226.75 | 249.59 | 244.40 | 67.63 | 57 |
| M005 | 12378.82 | 233.56 | 235.13 | 69.26 | 53 |
| M002 | 12085.47 | 236.97 | 232.70 | 70.57 | 51 |
| M003 | 10209.95 | 226.89 | 228.66 | 70.93 | 45 |
| M006 | 7857.32 | 245.54 | 244.08 | 64.31 | 32 |
venda_mensal_geral <- dados %>%
group_by(ano, mes) %>%
summarise(
Total_Vendas_Mensais = sum(venda_diaria, na.rm = TRUE),
qtd_corridas = n(),
.groups = "drop"
) %>%
arrange(ano, mes)
kable(venda_mensal_geral, digits = 2, caption = "Venda mensal total geral")
| ano | mes | Total_Vendas_Mensais | qtd_corridas |
|---|---|---|---|
| 2025 | 1 | 6112.75 | 26 |
| 2025 | 2 | 4019.27 | 16 |
| 2025 | 3 | 6923.76 | 28 |
| 2025 | 4 | 5287.04 | 21 |
| 2025 | 5 | 6950.04 | 29 |
| 2025 | 6 | 4430.10 | 19 |
| 2025 | 7 | 7150.82 | 30 |
| 2025 | 8 | 6799.63 | 29 |
| 2025 | 9 | 7461.76 | 30 |
| 2025 | 10 | 4971.54 | 20 |
| 2025 | 11 | 5947.26 | 26 |
| 2025 | 12 | 6292.04 | 26 |
venda_mensal_vendedor <- dados %>%
group_by(vendedor, ano, mes) %>%
summarise(
Total_Vendas_Mensais = sum(venda_diaria, na.rm = TRUE),
.groups = "drop"
) %>%
arrange(vendedor, ano, mes)
kable(venda_mensal_vendedor, digits = 2, caption = "Venda mensal total por vendedor")
| vendedor | ano | mes | Total_Vendas_Mensais |
|---|---|---|---|
| M001 | 2025 | 1 | 1025.16 |
| M001 | 2025 | 2 | 1402.90 |
| M001 | 2025 | 3 | 1520.61 |
| M001 | 2025 | 4 | 717.97 |
| M001 | 2025 | 5 | 1350.02 |
| M001 | 2025 | 6 | 257.09 |
| M001 | 2025 | 7 | 2109.87 |
| M001 | 2025 | 8 | 1117.85 |
| M001 | 2025 | 9 | 1687.72 |
| M001 | 2025 | 10 | 1435.99 |
| M001 | 2025 | 11 | 1022.42 |
| M001 | 2025 | 12 | 1940.10 |
| M002 | 2025 | 1 | 1228.92 |
| M002 | 2025 | 2 | 129.46 |
| M002 | 2025 | 3 | 1333.73 |
| M002 | 2025 | 4 | 678.62 |
| M002 | 2025 | 5 | 1494.54 |
| M002 | 2025 | 6 | 1637.25 |
| M002 | 2025 | 7 | 1160.01 |
| M002 | 2025 | 8 | 1317.96 |
| M002 | 2025 | 9 | 715.98 |
| M002 | 2025 | 10 | 730.91 |
| M002 | 2025 | 11 | 667.77 |
| M002 | 2025 | 12 | 990.32 |
| M003 | 2025 | 1 | 882.03 |
| M003 | 2025 | 2 | 1013.82 |
| M003 | 2025 | 3 | 160.38 |
| M003 | 2025 | 4 | 1605.08 |
| M003 | 2025 | 5 | 217.33 |
| M003 | 2025 | 6 | 1088.19 |
| M003 | 2025 | 7 | 1103.73 |
| M003 | 2025 | 8 | 667.07 |
| M003 | 2025 | 9 | 1074.09 |
| M003 | 2025 | 10 | 979.73 |
| M003 | 2025 | 11 | 427.78 |
| M003 | 2025 | 12 | 990.72 |
| M004 | 2025 | 1 | 1453.76 |
| M004 | 2025 | 2 | 325.50 |
| M004 | 2025 | 3 | 817.73 |
| M004 | 2025 | 4 | 778.72 |
| M004 | 2025 | 5 | 2188.87 |
| M004 | 2025 | 6 | 1324.67 |
| M004 | 2025 | 7 | 1281.55 |
| M004 | 2025 | 8 | 1731.86 |
| M004 | 2025 | 9 | 1359.93 |
| M004 | 2025 | 10 | 232.13 |
| M004 | 2025 | 11 | 1814.26 |
| M004 | 2025 | 12 | 917.77 |
| M005 | 2025 | 1 | 1040.60 |
| M005 | 2025 | 2 | 750.58 |
| M005 | 2025 | 3 | 1389.50 |
| M005 | 2025 | 4 | 988.25 |
| M005 | 2025 | 5 | 1078.73 |
| M005 | 2025 | 6 | 122.90 |
| M005 | 2025 | 7 | 874.02 |
| M005 | 2025 | 8 | 1212.82 |
| M005 | 2025 | 9 | 1924.68 |
| M005 | 2025 | 10 | 954.83 |
| M005 | 2025 | 11 | 1348.16 |
| M005 | 2025 | 12 | 693.75 |
| M006 | 2025 | 1 | 482.28 |
| M006 | 2025 | 2 | 397.01 |
| M006 | 2025 | 3 | 1701.81 |
| M006 | 2025 | 4 | 518.40 |
| M006 | 2025 | 5 | 620.55 |
| M006 | 2025 | 7 | 621.64 |
| M006 | 2025 | 8 | 752.07 |
| M006 | 2025 | 9 | 699.36 |
| M006 | 2025 | 10 | 637.95 |
| M006 | 2025 | 11 | 666.87 |
| M006 | 2025 | 12 | 759.38 |
ggplot(resumo_vendedor, aes(x = reorder(vendedor, venda_total), y = venda_total, fill = vendedor)) +
geom_col(show.legend = FALSE) +
coord_flip() +
labs(title = "Venda total por vendedor", x = "Vendedor", y = "Venda total (R$)") +
theme_minimal()
serie_mensal <- venda_mensal_geral %>%
mutate(data_mes = as.Date(sprintf("%d-%02d-01", ano, mes)))
ggplot(serie_mensal, aes(x = data_mes, y = Total_Vendas_Mensais)) +
geom_line(linewidth = 1) +
geom_point(size = 2.5) +
labs(title = "Tendência mensal das vendas totais", x = "Mês", y = "Total de vendas mensais (R$)") +
theme_minimal()
serie_vendedor_mes <- venda_mensal_vendedor %>%
mutate(data_mes = as.Date(sprintf("%d-%02d-01", ano, mes)))
ggplot(serie_vendedor_mes, aes(x = data_mes, y = Total_Vendas_Mensais, group = vendedor)) +
geom_line(linewidth = 0.9) +
geom_point(size = 1.8) +
facet_wrap(~ vendedor, scales = "free_y") +
labs(title = "Evolução das vendas mensais por vendedor", x = "Mês", y = "Total_Vendas_Mensais (R$)") +
theme_minimal()
ggplot(dados, aes(x = venda_diaria)) +
geom_histogram(bins = 20, color = "white", fill = "#2C3E50") +
labs(title = "Distribuição da venda diária", x = "Venda diária (R$)", y = "Frequência") +
theme_minimal()
ggplot(dados, aes(x = factor(mes), y = venda_diaria, fill = factor(mes))) +
geom_boxplot(show.legend = FALSE) +
labs(title = "Venda diária por mês", x = "Mês", y = "Venda diária (R$)") +
theme_minimal()
ggplot(dados, aes(x = reorder(vendedor, venda_diaria, FUN = median), y = venda_diaria, fill = vendedor)) +
geom_boxplot(show.legend = FALSE) +
labs(title = "Venda diária por vendedor", x = "Vendedor", y = "Venda diária (R$)") +
theme_minimal()
Fórmula aplicada: \[\text{Salário} = \text{Salário Base} + 0{,}05 \times \text{Vendas do Mês} - 0{,}08 \times \text{FGTS} - 0{,}11 \times \text{INSS}\]
(A planilha possui dados de 2025; abaixo o cálculo é exibido para
o mês de março — mes == 3 — com salário base ilustrativo de
R$ 2.500,00.)
salario_base <- 2500
folha_marco <- dados %>%
filter(mes == 3) %>%
group_by(vendedor, ano, mes) %>%
summarise(
total_vendas_mes = sum(venda_diaria, na.rm = TRUE),
.groups = "drop"
) %>%
mutate(
salario_base = salario_base,
comissao_5pct = 0.05 * total_vendas_mes,
fgts_8pct = 0.08 * total_vendas_mes,
inss_11pct = 0.11 * total_vendas_mes,
salario_liquido = salario_base + comissao_5pct - fgts_8pct - inss_11pct
)
kable(folha_marco, digits = 2, caption = "Folha de pagamento — mês de março")
| vendedor | ano | mes | total_vendas_mes | salario_base | comissao_5pct | fgts_8pct | inss_11pct | salario_liquido |
|---|---|---|---|---|---|---|---|---|
| M001 | 2025 | 3 | 1520.61 | 2500 | 76.03 | 121.65 | 167.27 | 2287.11 |
| M002 | 2025 | 3 | 1333.73 | 2500 | 66.69 | 106.70 | 146.71 | 2313.28 |
| M003 | 2025 | 3 | 160.38 | 2500 | 8.02 | 12.83 | 17.64 | 2477.55 |
| M004 | 2025 | 3 | 817.73 | 2500 | 40.89 | 65.42 | 89.95 | 2385.52 |
| M005 | 2025 | 3 | 1389.50 | 2500 | 69.48 | 111.16 | 152.84 | 2305.47 |
| M006 | 2025 | 3 | 1701.81 | 2500 | 85.09 | 136.14 | 187.20 | 2261.75 |
A análise exploratória reuniu o tratamento da base
Transporte_Executivo_RJ.xlsx, as métricas por vendedor e
por mês com dplyr, os seis gráficos em ggplot2
e o cálculo de remuneração com comissão e descontos previstos, pronto
para publicação no RPubs.