Rows: 66700 Columns: 7
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (6): BANDERA, NOMBRE COMERCIAL, PRODUCTO, FECHA REGISTRO, DEPARTAMENTO, ...
dbl (1): VALOR PRECIO
ℹ 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.
Rows: 74112 Columns: 7
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (6): BANDERA, NOMBRE COMERCIAL, PRODUCTO, FECHA REGISTRO, DEPARTAMENTO, ...
dbl (1): VALOR PRECIO
ℹ 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.
Rows: 62339 Columns: 7
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (6): BANDERA, NOMBRE COMERCIAL, PRODUCTO, FECHA REGISTRO, DEPARTAMENTO, ...
dbl (1): VALOR PRECIO
ℹ 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.
Rows: 64792 Columns: 7
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (6): BANDERA, NOMBRE COMERCIAL, PRODUCTO, FECHA REGISTRO, DEPARTAMENTO, ...
dbl (1): VALOR PRECIO
ℹ 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.
ℹ Google's Terms of Service: <https://mapsplatform.google.com>
Stadia Maps' Terms of Service: <https://stadiamaps.com/terms-of-service/>
OpenStreetMap's Tile Usage Policy: <https://operations.osmfoundation.org/policies/tiles/>
ℹ Please cite ggmap if you use it! Use `citation("ggmap")` for details.
Reading layer `COLOMBIA' from data source
`C:\Users\valcd\Downloads\Python _Act\Python _Act\coordenadas\COLOMBIA\COLOMBIA.shp'
using driver `ESRI Shapefile'
Simple feature collection with 33 features and 11 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -81.73575 ymin: -4.227907 xmax: -66.84735 ymax: 13.39453
Geodetic CRS: WGS 84
mapa_col <-st_make_valid(mapa_col)
library("stringr")dpto_1 <-tolower(data23_1$DEPARTAMENTO) dpto_2 <-tolower(mapa_col$DPTO_CNMBR) M1 <-which(is.na(match(dpto_1, dpto_2)))dpto_2 <-str_replace_all(dpto_2, "\\?", "ñ")dpto_2 <-str_replace_all(dpto_2, "archipielago de san andres", "san andres islas")data23_1$codigo <- dpto_1mapa_col$codigo <- dpto_2data_23_2 <-merge(st_drop_geometry(mapa_col), data23_1, by ="codigo", all =TRUE, sort =FALSE)data_23_3 <- data_23_2 %>%group_by(codigo, DPTO_NANO_, DPTO_NAREA, DPTO_CSMBL, DPTO_NANO, PAIS_PAIS_, SHAPE_Leng, SHAPE_Area) %>%summarize(precio_prom_dpto =mean(`VALOR PRECIO`)) %>%ungroup()
`summarise()` has grouped output by 'codigo', 'DPTO_NANO_', 'DPTO_NAREA',
'DPTO_CSMBL', 'DPTO_NANO', 'PAIS_PAIS_', 'SHAPE_Leng'. You can override using
the `.groups` argument.
data_23_3$precio_prom_dpto <-as.numeric(data_23_3$precio_prom_dpto)precio_fac <-cut(data_23_3$precio_prom_dpto, breaks =c(10000, 12000, 14000, 16000),labels =c("Bajo", "Medio", "Alto"))colores <-c("Bajo"="green","Medio"="orange","Alto"="red")if (length(precio_fac) ==nrow(data_23_3)) { data_23_3$color <- colores[precio_fac]cat("Colores asignados correctamente.\n")} else {stop("Error: La longitud de precio_fac no coincide con el número de filas en datos_unidos2.")}
Colores asignados correctamente.
data_23_4 <-merge(mapa_col, data_23_3, by ="codigo")