library("tidyverse")
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.2     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
setwd("/Users/patricioflores/Downloads/Files/Tec/Ago-Dic\ 2025/optativa/evidencia2")
getwd()
## [1] "/Users/patricioflores/Downloads/Files/Tec/Ago-Dic 2025/optativa/evidencia2"
encuesta <- read_csv("encuesta.csv")
## Rows: 25 Columns: 37
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (6): Marca temporal, Género, Orientación Sexual, Edad, Ocupación, Géner...
## dbl (30): Iris - Goo Goo Dolls, Beautiful Things - Benson Boone, Creep - Rad...
## lgl  (1): Puntuación
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
glimpse(encuesta)
## Rows: 25
## Columns: 37
## $ `Marca temporal`                                    <chr> "21/11/2025 11:04:…
## $ Puntuación                                          <lgl> NA, NA, NA, NA, NA…
## $ Género                                              <chr> "Hombre", "Hombre …
## $ `Orientación Sexual`                                <chr> "Heterosexual", "Q…
## $ Edad                                                <chr> "18-25", "45+", "1…
## $ Ocupación                                           <chr> "Estudiante", "Est…
## $ `Género Musical Favorito`                           <chr> "Punk/rock", "Rock…
## $ `Iris - Goo Goo Dolls`                              <dbl> 3, 5, 5, 5, 5, 3, …
## $ `Beautiful Things - Benson Boone`                   <dbl> 3, 2, 1, 4, 5, 3, …
## $ `Creep - Radiohead`                                 <dbl> 5, 5, 5, 5, 3, 4, …
## $ `Every Breath you Take - The Police`                <dbl> 3, 5, 5, 3, 4, 4, …
## $ `Yellow - Coldplay`                                 <dbl> 5, 4, 5, 3, 5, 5, …
## $ `Manchild - Sabrina Carpenter`                      <dbl> 5, 2, 1, 3, 5, 3, …
## $ `Espresso - Sabrina Carpenter`                      <dbl> 5, 2, 1, 3, 4, 4, …
## $ `Marlboro Rojo - Fuerza Regida`                     <dbl> 1, 1, 2, 2, 1, 2, …
## $ `Perlas Negras - Gabito Ballesteros, Natanael Cano` <dbl> 4, 1, 2, 2, 1, 2, …
## $ `Coqueta - Grupo Frontera`                          <dbl> 4, 1, 2, 4, 1, 3, …
## $ `Que Pasaría - Rauw Alejandro`                      <dbl> 2, 2, 3, 4, 5, 5, …
## $ `Baile Inolvidable - Bad Bunny`                     <dbl> 5, 5, 4, 5, 5, 5, …
## $ `Enseñame a Bailar - Bad Bunny`                     <dbl> 4, 3, 4, 4, 5, 5, …
## $ `Corazón Partío - Alejandro Saenz`                  <dbl> 5, 5, 5, 5, 3, 5, …
## $ `Cuando me enamoro -Enrique Iglesias`               <dbl> 3, 5, 4, 4, 5, 5, …
## $ `Azul - Cristian Castro`                            <dbl> 3, 4, 5, 4, 5, 4, …
## $ `Si te Pillara - Béele`                             <dbl> 1, 1, 1, 3, 3, 3, …
## $ `Yo y Tú - Quevedo y Béele`                         <dbl> 1, 1, 4, 3, 5, 3, …
## $ `All the Stars - Kendrick Lamar / SZA`              <dbl> 1, 4, 4, 3, 4, 5, …
## $ `Moves like Jagger -Maroon 5`                       <dbl> 2, 3, 4, 3, 5, 5, …
## $ `Counting Stars - One Republic`                     <dbl> 2, 4, 5, 4, 5, 5, …
## $ `Crazy train - Ozzy Ousbourne`                      <dbl> 2, 5, 5, 2, 3, 3, …
## $ `Sweet Child o Mine - Guns N Roses`                 <dbl> 4, 4, 5, 3, 2, 4, …
## $ `Stick Season - Noah Kahan`                         <dbl> 2, 2, 5, 3, 5, 3, …
## $ `Something in the Orange - Zach Bryan`              <dbl> 2, 4, 5, 5, 2, 3, …
## $ `Lamento Boliviano - enanitos Verdes`               <dbl> 5, 4, 5, 4, 2, 5, …
## $ `Música Ligera  Soda stereo`                        <dbl> 5, 4, 5, 5, 5, 5, …
## $ `Forever After All - Luke Combs`                    <dbl> 2, 2, 5, 4, 5, 3, …
## $ `That's So true - Gracie Abrams`                    <dbl> 2, 2, 4, 4, 5, 3, …
## $ `Bags - Clairo`                                     <dbl> 5, 3, 4, 2, 1, 3, …
head(encuesta)
## # A tibble: 6 × 37
##   `Marca temporal`    Puntuación Género     `Orientación Sexual` Edad  Ocupación
##   <chr>               <lgl>      <chr>      <chr>                <chr> <chr>    
## 1 21/11/2025 11:04:17 NA         Hombre     Heterosexual         18-25 Estudian…
## 2 21/11/2025 11:09:46 NA         Hombre Tr… Queer                45+   Estudian…
## 3 21/11/2025 11:11:15 NA         Hombre     Heterosexual         18-25 Estudian…
## 4 21/11/2025 11:17:50 NA         Hombre     Heterosexual         18-25 Estudian…
## 5 21/11/2025 11:24:47 NA         Mujer      Heterosexual         18-25 Estudian…
## 6 21/11/2025 11:26:12 NA         Hombre     Heterosexual         18-25 Estudian…
## # ℹ 31 more variables: `Género Musical Favorito` <chr>,
## #   `Iris - Goo Goo Dolls` <dbl>, `Beautiful Things - Benson Boone` <dbl>,
## #   `Creep - Radiohead` <dbl>, `Every Breath you Take - The Police` <dbl>,
## #   `Yellow - Coldplay` <dbl>, `Manchild - Sabrina Carpenter` <dbl>,
## #   `Espresso - Sabrina Carpenter` <dbl>,
## #   `Marlboro Rojo - Fuerza Regida` <dbl>,
## #   `Perlas Negras - Gabito Ballesteros, Natanael Cano` <dbl>, …
tail(encuesta)
## # A tibble: 6 × 37
##   `Marca temporal`    Puntuación Género `Orientación Sexual` Edad  Ocupación 
##   <chr>               <lgl>      <chr>  <chr>                <chr> <chr>     
## 1 28/11/2025 13:21:17 NA         Hombre Heterosexual         18-25 Estudiante
## 2 28/11/2025 14:58:16 NA         Hombre Heterosexual         18-25 Estudiante
## 3 28/11/2025 15:38:09 NA         Hombre Heterosexual         18-25 Estudiante
## 4 28/11/2025 15:49:54 NA         Hombre Heterosexual         18-25 Estudiante
## 5 2/12/2025 9:11:22   NA         Hombre Heterosexual         18-25 Estudiante
## 6 2/12/2025 9:12:25   NA         Mujer  Heterosexual         18-25 Estudiante
## # ℹ 31 more variables: `Género Musical Favorito` <chr>,
## #   `Iris - Goo Goo Dolls` <dbl>, `Beautiful Things - Benson Boone` <dbl>,
## #   `Creep - Radiohead` <dbl>, `Every Breath you Take - The Police` <dbl>,
## #   `Yellow - Coldplay` <dbl>, `Manchild - Sabrina Carpenter` <dbl>,
## #   `Espresso - Sabrina Carpenter` <dbl>,
## #   `Marlboro Rojo - Fuerza Regida` <dbl>,
## #   `Perlas Negras - Gabito Ballesteros, Natanael Cano` <dbl>, …
colnames(encuesta)
##  [1] "Marca temporal"                                   
##  [2] "Puntuación"                                       
##  [3] "Género"                                           
##  [4] "Orientación Sexual"                               
##  [5] "Edad"                                             
##  [6] "Ocupación"                                        
##  [7] "Género Musical Favorito"                          
##  [8] "Iris - Goo Goo Dolls"                             
##  [9] "Beautiful Things - Benson Boone"                  
## [10] "Creep - Radiohead"                                
## [11] "Every Breath you Take - The Police"               
## [12] "Yellow - Coldplay"                                
## [13] "Manchild - Sabrina Carpenter"                     
## [14] "Espresso - Sabrina Carpenter"                     
## [15] "Marlboro Rojo - Fuerza Regida"                    
## [16] "Perlas Negras - Gabito Ballesteros, Natanael Cano"
## [17] "Coqueta - Grupo Frontera"                         
## [18] "Que Pasaría - Rauw Alejandro"                     
## [19] "Baile Inolvidable - Bad Bunny"                    
## [20] "Enseñame a Bailar - Bad Bunny"                    
## [21] "Corazón Partío - Alejandro Saenz"                 
## [22] "Cuando me enamoro -Enrique Iglesias"              
## [23] "Azul - Cristian Castro"                           
## [24] "Si te Pillara - Béele"                            
## [25] "Yo y Tú - Quevedo y Béele"                        
## [26] "All the Stars - Kendrick Lamar / SZA"             
## [27] "Moves like Jagger -Maroon 5"                      
## [28] "Counting Stars - One Republic"                    
## [29] "Crazy train - Ozzy Ousbourne"                     
## [30] "Sweet Child o Mine - Guns N Roses"                
## [31] "Stick Season - Noah Kahan"                        
## [32] "Something in the Orange - Zach Bryan"             
## [33] "Lamento Boliviano - enanitos Verdes"              
## [34] "Música Ligera  Soda stereo"                       
## [35] "Forever After All - Luke Combs"                   
## [36] "That's So true - Gracie Abrams"                   
## [37] "Bags - Clairo"
encuesta <- encuesta %>%
  rename(
    genero_musical_favorito = `Género Musical Favorito`
  )
encuesta <- encuesta %>%
  rename(
    orientacion_sexual = `Orientación Sexual`,
    ocupacion = `Ocupación`,
    puntuacion = `Puntuación`,
  )
colnames(encuesta)
##  [1] "Marca temporal"                                   
##  [2] "puntuacion"                                       
##  [3] "Género"                                           
##  [4] "orientacion_sexual"                               
##  [5] "Edad"                                             
##  [6] "ocupacion"                                        
##  [7] "genero_musical_favorito"                          
##  [8] "Iris - Goo Goo Dolls"                             
##  [9] "Beautiful Things - Benson Boone"                  
## [10] "Creep - Radiohead"                                
## [11] "Every Breath you Take - The Police"               
## [12] "Yellow - Coldplay"                                
## [13] "Manchild - Sabrina Carpenter"                     
## [14] "Espresso - Sabrina Carpenter"                     
## [15] "Marlboro Rojo - Fuerza Regida"                    
## [16] "Perlas Negras - Gabito Ballesteros, Natanael Cano"
## [17] "Coqueta - Grupo Frontera"                         
## [18] "Que Pasaría - Rauw Alejandro"                     
## [19] "Baile Inolvidable - Bad Bunny"                    
## [20] "Enseñame a Bailar - Bad Bunny"                    
## [21] "Corazón Partío - Alejandro Saenz"                 
## [22] "Cuando me enamoro -Enrique Iglesias"              
## [23] "Azul - Cristian Castro"                           
## [24] "Si te Pillara - Béele"                            
## [25] "Yo y Tú - Quevedo y Béele"                        
## [26] "All the Stars - Kendrick Lamar / SZA"             
## [27] "Moves like Jagger -Maroon 5"                      
## [28] "Counting Stars - One Republic"                    
## [29] "Crazy train - Ozzy Ousbourne"                     
## [30] "Sweet Child o Mine - Guns N Roses"                
## [31] "Stick Season - Noah Kahan"                        
## [32] "Something in the Orange - Zach Bryan"             
## [33] "Lamento Boliviano - enanitos Verdes"              
## [34] "Música Ligera  Soda stereo"                       
## [35] "Forever After All - Luke Combs"                   
## [36] "That's So true - Gracie Abrams"                   
## [37] "Bags - Clairo"
encuesta <- encuesta %>%
  rename(
    genero = `Género`
  )
colnames(encuesta)
##  [1] "Marca temporal"                                   
##  [2] "puntuacion"                                       
##  [3] "genero"                                           
##  [4] "orientacion_sexual"                               
##  [5] "Edad"                                             
##  [6] "ocupacion"                                        
##  [7] "genero_musical_favorito"                          
##  [8] "Iris - Goo Goo Dolls"                             
##  [9] "Beautiful Things - Benson Boone"                  
## [10] "Creep - Radiohead"                                
## [11] "Every Breath you Take - The Police"               
## [12] "Yellow - Coldplay"                                
## [13] "Manchild - Sabrina Carpenter"                     
## [14] "Espresso - Sabrina Carpenter"                     
## [15] "Marlboro Rojo - Fuerza Regida"                    
## [16] "Perlas Negras - Gabito Ballesteros, Natanael Cano"
## [17] "Coqueta - Grupo Frontera"                         
## [18] "Que Pasaría - Rauw Alejandro"                     
## [19] "Baile Inolvidable - Bad Bunny"                    
## [20] "Enseñame a Bailar - Bad Bunny"                    
## [21] "Corazón Partío - Alejandro Saenz"                 
## [22] "Cuando me enamoro -Enrique Iglesias"              
## [23] "Azul - Cristian Castro"                           
## [24] "Si te Pillara - Béele"                            
## [25] "Yo y Tú - Quevedo y Béele"                        
## [26] "All the Stars - Kendrick Lamar / SZA"             
## [27] "Moves like Jagger -Maroon 5"                      
## [28] "Counting Stars - One Republic"                    
## [29] "Crazy train - Ozzy Ousbourne"                     
## [30] "Sweet Child o Mine - Guns N Roses"                
## [31] "Stick Season - Noah Kahan"                        
## [32] "Something in the Orange - Zach Bryan"             
## [33] "Lamento Boliviano - enanitos Verdes"              
## [34] "Música Ligera  Soda stereo"                       
## [35] "Forever After All - Luke Combs"                   
## [36] "That's So true - Gracie Abrams"                   
## [37] "Bags - Clairo"
#chatgpt el trim
encuesta <- encuesta %>%
  mutate(across(
    where(is.character),
    ~ str_to_lower(str_trim(.x))
  ))
head(encuesta)
## # A tibble: 6 × 37
##   `Marca temporal`    puntuacion genero       orientacion_sexual Edad  ocupacion
##   <chr>               <lgl>      <chr>        <chr>              <chr> <chr>    
## 1 21/11/2025 11:04:17 NA         hombre       heterosexual       18-25 estudian…
## 2 21/11/2025 11:09:46 NA         hombre trans queer              45+   estudian…
## 3 21/11/2025 11:11:15 NA         hombre       heterosexual       18-25 estudian…
## 4 21/11/2025 11:17:50 NA         hombre       heterosexual       18-25 estudian…
## 5 21/11/2025 11:24:47 NA         mujer        heterosexual       18-25 estudian…
## 6 21/11/2025 11:26:12 NA         hombre       heterosexual       18-25 estudian…
## # ℹ 31 more variables: genero_musical_favorito <chr>,
## #   `Iris - Goo Goo Dolls` <dbl>, `Beautiful Things - Benson Boone` <dbl>,
## #   `Creep - Radiohead` <dbl>, `Every Breath you Take - The Police` <dbl>,
## #   `Yellow - Coldplay` <dbl>, `Manchild - Sabrina Carpenter` <dbl>,
## #   `Espresso - Sabrina Carpenter` <dbl>,
## #   `Marlboro Rojo - Fuerza Regida` <dbl>,
## #   `Perlas Negras - Gabito Ballesteros, Natanael Cano` <dbl>, …
str(encuesta)
## tibble [25 × 37] (S3: tbl_df/tbl/data.frame)
##  $ Marca temporal                                   : chr [1:25] "21/11/2025 11:04:17" "21/11/2025 11:09:46" "21/11/2025 11:11:15" "21/11/2025 11:17:50" ...
##  $ puntuacion                                       : logi [1:25] NA NA NA NA NA NA ...
##  $ genero                                           : chr [1:25] "hombre" "hombre trans" "hombre" "hombre" ...
##  $ orientacion_sexual                               : chr [1:25] "heterosexual" "queer" "heterosexual" "heterosexual" ...
##  $ Edad                                             : chr [1:25] "18-25" "45+" "18-25" "18-25" ...
##  $ ocupacion                                        : chr [1:25] "estudiante" "estudiante" "estudiante" "estudiante" ...
##  $ genero_musical_favorito                          : chr [1:25] "punk/rock" "rock" "rock" "todos" ...
##  $ Iris - Goo Goo Dolls                             : num [1:25] 3 5 5 5 5 3 5 3 5 4 ...
##  $ Beautiful Things - Benson Boone                  : num [1:25] 3 2 1 4 5 3 3 4 1 2 ...
##  $ Creep - Radiohead                                : num [1:25] 5 5 5 5 3 4 4 3 3 1 ...
##  $ Every Breath you Take - The Police               : num [1:25] 3 5 5 3 4 4 3 3 3 5 ...
##  $ Yellow - Coldplay                                : num [1:25] 5 4 5 3 5 5 4 4 4 5 ...
##  $ Manchild - Sabrina Carpenter                     : num [1:25] 5 2 1 3 5 3 5 4 4 4 ...
##  $ Espresso - Sabrina Carpenter                     : num [1:25] 5 2 1 3 4 4 3 4 4 4 ...
##  $ Marlboro Rojo - Fuerza Regida                    : num [1:25] 1 1 2 2 1 2 2 3 2 3 ...
##  $ Perlas Negras - Gabito Ballesteros, Natanael Cano: num [1:25] 4 1 2 2 1 2 2 3 3 4 ...
##  $ Coqueta - Grupo Frontera                         : num [1:25] 4 1 2 4 1 3 2 4 3 3 ...
##  $ Que Pasaría - Rauw Alejandro                     : num [1:25] 2 2 3 4 5 5 4 5 3 5 ...
##  $ Baile Inolvidable - Bad Bunny                    : num [1:25] 5 5 4 5 5 5 5 5 5 5 ...
##  $ Enseñame a Bailar - Bad Bunny                    : num [1:25] 4 3 4 4 5 5 4 5 5 5 ...
##  $ Corazón Partío - Alejandro Saenz                 : num [1:25] 5 5 5 5 3 5 5 5 3 5 ...
##  $ Cuando me enamoro -Enrique Iglesias              : num [1:25] 3 5 4 4 5 5 5 5 3 5 ...
##  $ Azul - Cristian Castro                           : num [1:25] 3 4 5 4 5 4 4 5 4 5 ...
##  $ Si te Pillara - Béele                            : num [1:25] 1 1 1 3 3 3 3 5 3 4 ...
##  $ Yo y Tú - Quevedo y Béele                        : num [1:25] 1 1 4 3 5 3 3 5 4 5 ...
##  $ All the Stars - Kendrick Lamar / SZA             : num [1:25] 1 4 4 3 4 5 4 3 5 5 ...
##  $ Moves like Jagger -Maroon 5                      : num [1:25] 2 3 4 3 5 5 4 5 5 5 ...
##  $ Counting Stars - One Republic                    : num [1:25] 2 4 5 4 5 5 4 5 5 4 ...
##  $ Crazy train - Ozzy Ousbourne                     : num [1:25] 2 5 5 2 3 3 4 5 4 4 ...
##  $ Sweet Child o Mine - Guns N Roses                : num [1:25] 4 4 5 3 2 4 4 5 4 5 ...
##  $ Stick Season - Noah Kahan                        : num [1:25] 2 2 5 3 5 3 5 3 5 5 ...
##  $ Something in the Orange - Zach Bryan             : num [1:25] 2 4 5 5 2 3 5 3 5 5 ...
##  $ Lamento Boliviano - enanitos Verdes              : num [1:25] 5 4 5 4 2 5 5 5 3 5 ...
##  $ Música Ligera  Soda stereo                       : num [1:25] 5 4 5 5 5 5 5 5 3 5 ...
##  $ Forever After All - Luke Combs                   : num [1:25] 2 2 5 4 5 3 3 3 3 5 ...
##  $ That's So true - Gracie Abrams                   : num [1:25] 2 2 4 4 5 3 5 3 4 5 ...
##  $ Bags - Clairo                                    : num [1:25] 5 3 4 2 1 3 4 3 3 5 ...
encuesta %>%
  count(genero_musical_favorito) %>%
  ggplot(aes(x = genero_musical_favorito, y = n)) +
  geom_col() +
  coord_flip()

colnames(encuesta)
##  [1] "Marca temporal"                                   
##  [2] "puntuacion"                                       
##  [3] "genero"                                           
##  [4] "orientacion_sexual"                               
##  [5] "Edad"                                             
##  [6] "ocupacion"                                        
##  [7] "genero_musical_favorito"                          
##  [8] "Iris - Goo Goo Dolls"                             
##  [9] "Beautiful Things - Benson Boone"                  
## [10] "Creep - Radiohead"                                
## [11] "Every Breath you Take - The Police"               
## [12] "Yellow - Coldplay"                                
## [13] "Manchild - Sabrina Carpenter"                     
## [14] "Espresso - Sabrina Carpenter"                     
## [15] "Marlboro Rojo - Fuerza Regida"                    
## [16] "Perlas Negras - Gabito Ballesteros, Natanael Cano"
## [17] "Coqueta - Grupo Frontera"                         
## [18] "Que Pasaría - Rauw Alejandro"                     
## [19] "Baile Inolvidable - Bad Bunny"                    
## [20] "Enseñame a Bailar - Bad Bunny"                    
## [21] "Corazón Partío - Alejandro Saenz"                 
## [22] "Cuando me enamoro -Enrique Iglesias"              
## [23] "Azul - Cristian Castro"                           
## [24] "Si te Pillara - Béele"                            
## [25] "Yo y Tú - Quevedo y Béele"                        
## [26] "All the Stars - Kendrick Lamar / SZA"             
## [27] "Moves like Jagger -Maroon 5"                      
## [28] "Counting Stars - One Republic"                    
## [29] "Crazy train - Ozzy Ousbourne"                     
## [30] "Sweet Child o Mine - Guns N Roses"                
## [31] "Stick Season - Noah Kahan"                        
## [32] "Something in the Orange - Zach Bryan"             
## [33] "Lamento Boliviano - enanitos Verdes"              
## [34] "Música Ligera  Soda stereo"                       
## [35] "Forever After All - Luke Combs"                   
## [36] "That's So true - Gracie Abrams"                   
## [37] "Bags - Clairo"
encuesta %>%
  ggplot(aes(x = `Iris - Goo Goo Dolls`)) +
  geom_histogram(bins = 10)

#chatgpt para hacer la gráfica
encuesta %>%
  count(Edad, genero_musical_favorito) %>%
  group_by(Edad) %>%
  mutate(prop = n / sum(n)) %>%
  ggplot(aes(x = Edad, y = prop, fill = genero_musical_favorito)) +
  geom_col(position = "fill") +
  scale_y_continuous(labels = scales::percent_format()) +
  labs(
    title = "Relación entre edad y género musical favorito",
    x = "Edad",
    y = "Porcentaje dentro del grupo de edad",
    fill = "Género musical"
  ) +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 14, face = "bold"),
    axis.text.x = element_text(angle = 45, hjust = 1)
  )

glimpse(encuesta)
## Rows: 25
## Columns: 37
## $ `Marca temporal`                                    <chr> "21/11/2025 11:04:…
## $ puntuacion                                          <lgl> NA, NA, NA, NA, NA…
## $ genero                                              <chr> "hombre", "hombre …
## $ orientacion_sexual                                  <chr> "heterosexual", "q…
## $ Edad                                                <chr> "18-25", "45+", "1…
## $ ocupacion                                           <chr> "estudiante", "est…
## $ genero_musical_favorito                             <chr> "punk/rock", "rock…
## $ `Iris - Goo Goo Dolls`                              <dbl> 3, 5, 5, 5, 5, 3, …
## $ `Beautiful Things - Benson Boone`                   <dbl> 3, 2, 1, 4, 5, 3, …
## $ `Creep - Radiohead`                                 <dbl> 5, 5, 5, 5, 3, 4, …
## $ `Every Breath you Take - The Police`                <dbl> 3, 5, 5, 3, 4, 4, …
## $ `Yellow - Coldplay`                                 <dbl> 5, 4, 5, 3, 5, 5, …
## $ `Manchild - Sabrina Carpenter`                      <dbl> 5, 2, 1, 3, 5, 3, …
## $ `Espresso - Sabrina Carpenter`                      <dbl> 5, 2, 1, 3, 4, 4, …
## $ `Marlboro Rojo - Fuerza Regida`                     <dbl> 1, 1, 2, 2, 1, 2, …
## $ `Perlas Negras - Gabito Ballesteros, Natanael Cano` <dbl> 4, 1, 2, 2, 1, 2, …
## $ `Coqueta - Grupo Frontera`                          <dbl> 4, 1, 2, 4, 1, 3, …
## $ `Que Pasaría - Rauw Alejandro`                      <dbl> 2, 2, 3, 4, 5, 5, …
## $ `Baile Inolvidable - Bad Bunny`                     <dbl> 5, 5, 4, 5, 5, 5, …
## $ `Enseñame a Bailar - Bad Bunny`                     <dbl> 4, 3, 4, 4, 5, 5, …
## $ `Corazón Partío - Alejandro Saenz`                  <dbl> 5, 5, 5, 5, 3, 5, …
## $ `Cuando me enamoro -Enrique Iglesias`               <dbl> 3, 5, 4, 4, 5, 5, …
## $ `Azul - Cristian Castro`                            <dbl> 3, 4, 5, 4, 5, 4, …
## $ `Si te Pillara - Béele`                             <dbl> 1, 1, 1, 3, 3, 3, …
## $ `Yo y Tú - Quevedo y Béele`                         <dbl> 1, 1, 4, 3, 5, 3, …
## $ `All the Stars - Kendrick Lamar / SZA`              <dbl> 1, 4, 4, 3, 4, 5, …
## $ `Moves like Jagger -Maroon 5`                       <dbl> 2, 3, 4, 3, 5, 5, …
## $ `Counting Stars - One Republic`                     <dbl> 2, 4, 5, 4, 5, 5, …
## $ `Crazy train - Ozzy Ousbourne`                      <dbl> 2, 5, 5, 2, 3, 3, …
## $ `Sweet Child o Mine - Guns N Roses`                 <dbl> 4, 4, 5, 3, 2, 4, …
## $ `Stick Season - Noah Kahan`                         <dbl> 2, 2, 5, 3, 5, 3, …
## $ `Something in the Orange - Zach Bryan`              <dbl> 2, 4, 5, 5, 2, 3, …
## $ `Lamento Boliviano - enanitos Verdes`               <dbl> 5, 4, 5, 4, 2, 5, …
## $ `Música Ligera  Soda stereo`                        <dbl> 5, 4, 5, 5, 5, 5, …
## $ `Forever After All - Luke Combs`                    <dbl> 2, 2, 5, 4, 5, 3, …
## $ `That's So true - Gracie Abrams`                    <dbl> 2, 2, 4, 4, 5, 3, …
## $ `Bags - Clairo`                                     <dbl> 5, 3, 4, 2, 1, 3, …
encuesta <- encuesta %>%
  mutate(
    genero_musical_favorito = case_when(
      genero_musical_favorito %in% c("reggaeton", "reggeaton") ~ "reggaeton",
      TRUE ~ genero_musical_favorito
    )
  )

encuesta %>%
  count(ocupacion, genero_musical_favorito) %>%
  group_by(ocupacion) %>%
  mutate(prop = n / sum(n)) %>%
  ggplot(aes(x = ocupacion, y = prop, fill = genero_musical_favorito)) +
  geom_col(position = "fill") +
  scale_y_continuous(labels = scales::percent_format()) +
  labs(
    title = "Relación entre ocupación y género musical favorito",
    x = "Ocupación",
    y = "Porcentaje dentro de cada ocupación",
    fill = "Género musical"
  ) +
  theme_minimal() +
  theme(
    plot.title  = element_text(size = 14, face = "bold"),
    axis.text.x = element_text(angle = 45, hjust = 1)
  )

encuesta %>%
  count(genero, genero_musical_favorito) %>%
  group_by(genero) %>%
  mutate(prop = n / sum(n)) %>%
  ggplot(aes(x = genero, y = prop, fill = genero_musical_favorito)) +
  geom_col(position = "fill") +
  scale_y_continuous(labels = scales::percent_format()) +
  labs(
    title = "Relación entre género y género musical favorito",
    x = "Género de la persona encuestada",
    y = "Porcentaje dentro de cada género",
    fill = "Género musical favorito"
  ) +
  theme_minimal() +
  theme(
    plot.title  = element_text(size = 14, face = "bold"),
    axis.text.x = element_text(angle = 45, hjust = 1)
  )

encuesta %>%
  count(genero_musical_favorito) %>%
  mutate(prop = n / sum(n)) %>%
  ggplot(aes(x = reorder(genero_musical_favorito, prop), y = prop)) +
  geom_col(fill = "darkgreen") +
  scale_y_continuous(labels = scales::percent_format()) +
  coord_flip() +
  labs(
    title = "Género musical favorito (porcentaje)",
    x = "Género musical",
    y = "Porcentaje de participantes"
  ) +
  theme_minimal()

encuesta %>%
  count(genero) %>%
  mutate(prop = n / sum(n)) %>%
  ggplot(aes(x = reorder(genero, prop), y = prop, fill = genero)) +
  geom_col() +
  scale_y_continuous(labels = scales::percent_format()) +
  coord_flip() +
  labs(
    title = "Distribución de personas por género (porcentaje)",
    x = "Género",
    y = "Porcentaje de participantes"
  ) +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 14, face = "bold"),
    legend.position = "none"
  )