Loading packages and dataset

pacotes <- c("readxl", "dplyr")
lapply(pacotes, library, character.only = TRUE)
cars_train <- read_excel("cars_train.xlsx")

Analyses

Usando table para olhar as marcas disponíveis:

table(cars_train$marca)
## 
##    ALFA ROMEO          AUDI           BMW           BRM         CHERY 
##             9          1698          1784             1           153 
##     CHEVROLET      CHRYSLER       CITROËN         DODGE          EFFA 
##          3020            30           194            37             1 
##       FERRARI          FIAT          FORD         HONDA       HYUNDAI 
##             1          1918          1060          1586          2043 
##         IVECO           JAC        JAGUAR          JEEP           KIA 
##             2             3           148          2000           408 
##    LAND ROVER         LEXUS         LIFAN      MASERATI MERCEDES-BENZ 
##           760            75             8             7          1125 
##          MINI    MITSUBISHI        NISSAN       PEUGEOT       PORSCHE 
##           137           862           438          1675           349 
##           RAM       RENAULT         SMART     SSANGYONG        SUBARU 
##           168           538            12            14            41 
##        SUZUKI        TOYOTA       TROLLER    VOLKSWAGEN         VOLVO 
##            41          2180           177          4594           287

Creating a new dataset only with luxury brands:

luxo <- filter(cars_train, marca %in% c("ALFA ROMEO", "AUDI", "BMW", "CHRYSLER", "FERRARI", "JAGUAR", "LAND ROVER", "LEXUS", "MASERATI", "MERCEDES-BENZ", "PORSCHE"))

States with the highest volumes of observations for luxury cars

vendas_por_estado <- luxo %>%
  group_by(estado_vendedor) %>%
  summarise(total_vendas = n()) %>%
  arrange(desc(total_vendas))
  top_10_estados <- head(vendas_por_estado, 10)
  top_10_estados
## # A tibble: 10 × 2
##    estado_vendedor          total_vendas
##    <chr>                           <int>
##  1 São Paulo (SP)                   3296
##  2 Paraná (PR)                       586
##  3 Rio de Janeiro (RJ)               530
##  4 Santa Catarina (SC)               477
##  5 Rio Grande do Sul (RS)            402
##  6 Minas Gerais (MG)                 372
##  7 Goiás (GO)                        159
##  8 Bahia (BA)                         90
##  9 Pernambuco (PE)                    42
## 10 Rio Grande do Norte (RN)            8

Calculating the average price of “luxury” cars for each state

luxo_top_estados <- filter(luxo, estado_vendedor %in% top_10_estados$estado_vendedor)
media_preco_por_estado <- luxo_top_estados %>%
  group_by(estado_vendedor) %>%
  summarize(media_preco = mean(preco)) %>%
  arrange(desc(media_preco))
  media_preco_por_estado
## # A tibble: 10 × 2
##    estado_vendedor          media_preco
##    <chr>                          <dbl>
##  1 Goiás (GO)                   213640.
##  2 Paraná (PR)                  203967.
##  3 Santa Catarina (SC)          197541.
##  4 Bahia (BA)                   193282.
##  5 São Paulo (SP)               192419.
##  6 Rio de Janeiro (RJ)          191248.
##  7 Rio Grande do Sul (RS)       190896.
##  8 Rio Grande do Norte (RN)     190682.
##  9 Minas Gerais (MG)            183592.
## 10 Pernambuco (PE)              180353.

Counting the number of observations by brand and state in the “luxo” dataset

vendas_por_marca_estado <- luxo %>%
  group_by(estado_vendedor, marca) %>%
  count() %>%
  arrange(estado_vendedor, desc(n))
marca_mais_vendida_por_estado <- vendas_por_marca_estado %>%
  group_by(estado_vendedor) %>%
  slice(1) %>%
  ungroup() %>%
  arrange(desc(n))
marca_mais_vendida_por_estado
## # A tibble: 18 × 3
##    estado_vendedor          marca             n
##    <chr>                    <chr>         <int>
##  1 São Paulo (SP)           AUDI            977
##  2 Paraná (PR)              BMW             208
##  3 Rio de Janeiro (RJ)      BMW             159
##  4 Santa Catarina (SC)      AUDI            145
##  5 Rio Grande do Sul (RS)   BMW             122
##  6 Minas Gerais (MG)        BMW             112
##  7 Goiás (GO)               BMW              62
##  8 Bahia (BA)               AUDI             37
##  9 Pernambuco (PE)          AUDI             18
## 10 Sergipe (SE)             BMW               6
## 11 Ceará (CE)               AUDI              4
## 12 Rio Grande do Norte (RN) AUDI              4
## 13 Pará (PA)                AUDI              3
## 14 Mato Grosso do Sul (MS)  BMW               2
## 15 Acre (AC)                BMW               1
## 16 Alagoas (AL)             LEXUS             1
## 17 Amazonas (AM)            MERCEDES-BENZ     1
## 18 Mato Grosso (MT)         BMW               1

Analyzing the “cars_train” dataset, we observe that the state of Paraná has the second highest volume of observations and the second highest average price for luxury cars. Knowing that the state of São Paulo is not being considered, we can conclude that, based on this data, the state of Paraná would be a favorable choice to open the dealership.

The BMW brand stands out as the most sold in the state of Paraná, demonstrating that a luxury dealership opened in this state should focus on selling BMW brand cars.

It is important to note that we did not specifically evaluate the average price of BMW brand cars, but rather the average price of luxury cars in general. Thus, as Paraná has the highest average price for luxury cars, we can infer that the population of this state has a good acceptance to pay higher values for luxury cars. In addition, the preference of Paraná residents for the BMW brand provides another indication for choosing this brand at the dealership.

These combined indicators provide a solid basis for making the decision to open a luxury dealership in the state of Paraná focused on the BMW brand.