1. Análisis de Componentes Principales (PCA):

#library(paqueteMODELOS)
#data(vivienda)
#str(vivienda)

library(tm)
## Loading required package: NLP
library(word2vec)
library(readr)

# Leer el archivo CSV
data <- read_csv("vivienda.csv")
## Rows: 8322 Columns: 13
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (3): zona, tipo, barrio
## dbl (10): id, piso, estrato, preciom, areaconst, parquea, banios, habitac, l...
## 
## ℹ 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.
# Mostrar las primeras filas del dataframe
head(data)
## # A tibble: 6 × 13
##      id zona        piso estrato preciom areaconst parquea banios habitac tipo  
##   <dbl> <chr>      <dbl>   <dbl>   <dbl>     <dbl>   <dbl>  <dbl>   <dbl> <chr> 
## 1  8312 Zona Oeste     4       6    1300       318       2      4       2 Apart…
## 2  8311 Zona Oeste     1       6     480       300       1      4       4 Casa  
## 3  8307 Zona Oeste    NA       5    1200       800       4      7       5 Casa  
## 4  8296 Zona Sur       2       3     220       150       1      2       4 Casa  
## 5  8297 Zona Oeste    NA       5     330       112       2      4       3 Casa  
## 6  8298 Zona Sur      NA       5    1350       390       8     10      10 Casa  
## # ℹ 3 more variables: barrio <chr>, longitud <dbl>, latitud <dbl>
# Explorar la estructura de los datos
str(data)
## spc_tbl_ [8,322 × 13] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ id       : num [1:8322] 8312 8311 8307 8296 8297 ...
##  $ zona     : chr [1:8322] "Zona Oeste" "Zona Oeste" "Zona Oeste" "Zona Sur" ...
##  $ piso     : num [1:8322] 4 1 NA 2 NA NA 2 NA NA 2 ...
##  $ estrato  : num [1:8322] 6 6 5 3 5 5 6 5 5 5 ...
##  $ preciom  : num [1:8322] 1300 480 1200 220 330 1350 305 480 275 285 ...
##  $ areaconst: num [1:8322] 318 300 800 150 112 390 125 280 74 120 ...
##  $ parquea  : num [1:8322] 2 1 4 1 2 8 2 4 1 2 ...
##  $ banios   : num [1:8322] 4 4 7 2 4 10 3 4 2 4 ...
##  $ habitac  : num [1:8322] 2 4 5 4 3 10 3 4 3 3 ...
##  $ tipo     : chr [1:8322] "Apartamento" "Casa" "Casa" "Casa" ...
##  $ barrio   : chr [1:8322] "arboleda" "normandía" "miraflores" "el guabal" ...
##  $ longitud : num [1:8322] -76576 -76571 -76568 -76565 -76565 ...
##  $ latitud  : num [1:8322] 3454 3454 3455 3417 3408 ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   id = col_double(),
##   ..   zona = col_character(),
##   ..   piso = col_double(),
##   ..   estrato = col_double(),
##   ..   preciom = col_double(),
##   ..   areaconst = col_double(),
##   ..   parquea = col_double(),
##   ..   banios = col_double(),
##   ..   habitac = col_double(),
##   ..   tipo = col_character(),
##   ..   barrio = col_character(),
##   ..   longitud = col_double(),
##   ..   latitud = col_double()
##   .. )
##  - attr(*, "problems")=<externalptr>
# Resumen estadístico de los datos
summary(data)
##        id           zona                piso           estrato     
##  Min.   :   1   Length:8322        Min.   : 1.000   Min.   :3.000  
##  1st Qu.:2080   Class :character   1st Qu.: 2.000   1st Qu.:4.000  
##  Median :4160   Mode  :character   Median : 3.000   Median :5.000  
##  Mean   :4160                      Mean   : 3.771   Mean   :4.634  
##  3rd Qu.:6240                      3rd Qu.: 5.000   3rd Qu.:5.000  
##  Max.   :8319                      Max.   :12.000   Max.   :6.000  
##  NA's   :3                         NA's   :2638     NA's   :3      
##     preciom         areaconst         parquea           banios      
##  Min.   :  58.0   Min.   :  30.0   Min.   : 1.000   Min.   : 0.000  
##  1st Qu.: 220.0   1st Qu.:  80.0   1st Qu.: 1.000   1st Qu.: 2.000  
##  Median : 330.0   Median : 123.0   Median : 2.000   Median : 3.000  
##  Mean   : 433.9   Mean   : 174.9   Mean   : 1.835   Mean   : 3.111  
##  3rd Qu.: 540.0   3rd Qu.: 229.0   3rd Qu.: 2.000   3rd Qu.: 4.000  
##  Max.   :1999.0   Max.   :1745.0   Max.   :10.000   Max.   :10.000  
##  NA's   :2        NA's   :3        NA's   :1605     NA's   :3       
##     habitac           tipo              barrio             longitud        
##  Min.   : 0.000   Length:8322        Length:8322        Min.   :-76576.00  
##  1st Qu.: 3.000   Class :character   Class :character   1st Qu.:-76507.00  
##  Median : 3.000   Mode  :character   Mode  :character   Median :   -76.54  
##  Mean   : 3.605                                         Mean   :-21866.06  
##  3rd Qu.: 4.000                                         3rd Qu.:   -76.52  
##  Max.   :10.000                                         Max.   :   -76.46  
##  NA's   :3                                              NA's   :3          
##     latitud        
##  Min.   :   3.333  
##  1st Qu.:   3.390  
##  Median :   3.449  
##  Mean   : 971.300  
##  3rd Qu.:3367.000  
##  Max.   :3497.000  
##  NA's   :3

2. Análisis de Conglomerados:

3. Análisis de Correspondencia:

4. Visualización de Resultados: