03 | Tarea: Descubriendo patrones temporales y espaciales en los datos

library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.3     v purrr   0.3.4
## v tibble  3.1.0     v dplyr   1.0.5
## v tidyr   1.1.3     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(sf)
## Warning: package 'sf' was built under R version 4.0.5
## Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(osmdata)
## Warning: package 'osmdata' was built under R version 4.0.5
## Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
library(leaflet)
## Warning: package 'leaflet' was built under R version 4.0.5
library(ggmap)
## Warning: package 'ggmap' was built under R version 4.0.5
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
library(lubridate)
## Warning: package 'lubridate' was built under R version 4.0.5
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union

Importamos el dataset de Obras registradas en la Ciudad Autónoma de Buenos Aires disponible en BA Datos Abiertos

obras_registradas <- read.csv("obrasregistradas-acumulado.csv", stringsAsFactors = TRUE)
summary(obras_registradas)
##     Seccion        Manzana        Parcela               SMP      
##         :1110          :1125          :1128    - -        :1108  
##  083    : 130   058    :  50   016    : 134   None- -     :  17  
##  065    : 125   017    :  45   004    : 123   025-059-026 :   4  
##  035    : 122   032    :  45   003    : 122   033-073-024 :   4  
##  037    : 120   007    :  44   011    : 121   037-025-016c:   4  
##  033    : 118   020    :  44   002    : 117   042-041-022 :   4  
##  (Other):4302   (Other):4674   (Other):4282   (Other)     :4886  
##        Expediente                      Nomenclacion.par  Fecha.de.registro
##  30880890/18:   8                              :1109    2019-12-30:  97   
##  18184115/17:   7   2019/01/16                 :   9    2018-12-20:  62   
##  18984559/18:   7   17-33-77-3a/5/8/9          :   8    2019-01-02:  55   
##  16079848/19:   6   16-51-101-1a/1b/2/3/4/28/29:   7    2019-07-18:  54   
##  18069223/18:   6   16-43-73-16/17/18          :   6    2019-12-18:  53   
##  30958421/18:   6   17-33-58-22/23             :   6    2019-12-07:  42   
##  (Other)    :5987   (Other)                    :4882    (Other)   :5664   
##               Direccion         Comuna.1    Codigo.postal 
##  SIN NOMBRE        :  57   Comuna 12: 855   Min.   :1001  
##  A.THOMAS 444      :   8   Comuna 11: 668   1st Qu.:1406  
##  S/NOMBRE          :   8   Comuna 15: 598   Median :1417  
##  COCHABAMBA 354/70 :   7   Comuna 13: 551   Mean   :1379  
##  ECHEVERRIA 4230/44:   7   Comuna 14: 508   3rd Qu.:1428  
##  S/N - S/N         :   7   Comuna 10: 427   Max.   :1440  
##  (Other)           :5933   (Other)  :2420   NA's   :151   
##  Codigo.postal.argentino           Tipo.obra    Superficie..m2.   
##          : 151                          :1037   Min.   :     1.0  
##  C1427CCR:   8           Micro Obra     : 482   1st Qu.:   158.1  
##  C1150AAD:   7           Obra Mayor     :1188   Median :   761.0  
##  C1414CTU:   7           Obra Media     :2026   Mean   :  1890.0  
##  C1427EGA:   7           Obra Menor     :1267   3rd Qu.:  1847.3  
##  C1430BTT:   7           SIN INFORMACION:  27   Max.   :160317.0  
##  (Other) :5840                                  NA's   :552       
##             Direccion.normalizada      Lon              Lat        
##                        : 113      Min.   :-58.53   Min.   :-34.69  
##  ALVAREZ THOMAS AV. 444:   8      1st Qu.:-58.49   1st Qu.:-34.62  
##  COCHABAMBA 354        :   7      Median :-58.46   Median :-34.60  
##  ECHEVERRIA 4230       :   7      Mean   :-58.46   Mean   :-34.60  
##  CASTILLO 1659         :   6      3rd Qu.:-58.43   3rd Qu.:-34.58  
##  HUMBOLDT 1925         :   6      Max.   :-58.34   Max.   :-34.54  
##  (Other)               :5880      NA's   :127      NA's   :127     
##              Calle          Altura               Barrio         Comuna      
##                 : 113          : 126   Palermo      : 354   Min.   : 1.000  
##  CORDOBA AV.    :  44   1055   :  11   Villa Urquiza: 277   1st Qu.: 7.000  
##  PARAGUAY       :  38   1631   :  10   Caballito    : 258   Median :11.000  
##  HUMBOLDT       :  34   2256   :  10   Villa Devoto : 195   Mean   : 9.795  
##  TRIUNVIRATO AV.:  32   332    :  10   Flores       : 193   3rd Qu.:13.000  
##  BONIFACIO, JOSE:  31   444    :  10   Saavedra     : 174   Max.   :15.000  
##  (Other)        :5735   (Other):5850   (Other)      :4576   NA's   :127

Corregimos el parámetro de fecha para poder explotarlo

obras_registradas <- obras_registradas %>% 
  mutate(fecha_registro=ymd(Fecha.de.registro))
summary(obras_registradas)
##     Seccion        Manzana        Parcela               SMP      
##         :1110          :1125          :1128    - -        :1108  
##  083    : 130   058    :  50   016    : 134   None- -     :  17  
##  065    : 125   017    :  45   004    : 123   025-059-026 :   4  
##  035    : 122   032    :  45   003    : 122   033-073-024 :   4  
##  037    : 120   007    :  44   011    : 121   037-025-016c:   4  
##  033    : 118   020    :  44   002    : 117   042-041-022 :   4  
##  (Other):4302   (Other):4674   (Other):4282   (Other)     :4886  
##        Expediente                      Nomenclacion.par  Fecha.de.registro
##  30880890/18:   8                              :1109    2019-12-30:  97   
##  18184115/17:   7   2019/01/16                 :   9    2018-12-20:  62   
##  18984559/18:   7   17-33-77-3a/5/8/9          :   8    2019-01-02:  55   
##  16079848/19:   6   16-51-101-1a/1b/2/3/4/28/29:   7    2019-07-18:  54   
##  18069223/18:   6   16-43-73-16/17/18          :   6    2019-12-18:  53   
##  30958421/18:   6   17-33-58-22/23             :   6    2019-12-07:  42   
##  (Other)    :5987   (Other)                    :4882    (Other)   :5664   
##               Direccion         Comuna.1    Codigo.postal 
##  SIN NOMBRE        :  57   Comuna 12: 855   Min.   :1001  
##  A.THOMAS 444      :   8   Comuna 11: 668   1st Qu.:1406  
##  S/NOMBRE          :   8   Comuna 15: 598   Median :1417  
##  COCHABAMBA 354/70 :   7   Comuna 13: 551   Mean   :1379  
##  ECHEVERRIA 4230/44:   7   Comuna 14: 508   3rd Qu.:1428  
##  S/N - S/N         :   7   Comuna 10: 427   Max.   :1440  
##  (Other)           :5933   (Other)  :2420   NA's   :151   
##  Codigo.postal.argentino           Tipo.obra    Superficie..m2.   
##          : 151                          :1037   Min.   :     1.0  
##  C1427CCR:   8           Micro Obra     : 482   1st Qu.:   158.1  
##  C1150AAD:   7           Obra Mayor     :1188   Median :   761.0  
##  C1414CTU:   7           Obra Media     :2026   Mean   :  1890.0  
##  C1427EGA:   7           Obra Menor     :1267   3rd Qu.:  1847.3  
##  C1430BTT:   7           SIN INFORMACION:  27   Max.   :160317.0  
##  (Other) :5840                                  NA's   :552       
##             Direccion.normalizada      Lon              Lat        
##                        : 113      Min.   :-58.53   Min.   :-34.69  
##  ALVAREZ THOMAS AV. 444:   8      1st Qu.:-58.49   1st Qu.:-34.62  
##  COCHABAMBA 354        :   7      Median :-58.46   Median :-34.60  
##  ECHEVERRIA 4230       :   7      Mean   :-58.46   Mean   :-34.60  
##  CASTILLO 1659         :   6      3rd Qu.:-58.43   3rd Qu.:-34.58  
##  HUMBOLDT 1925         :   6      Max.   :-58.34   Max.   :-34.54  
##  (Other)               :5880      NA's   :127      NA's   :127     
##              Calle          Altura               Barrio         Comuna      
##                 : 113          : 126   Palermo      : 354   Min.   : 1.000  
##  CORDOBA AV.    :  44   1055   :  11   Villa Urquiza: 277   1st Qu.: 7.000  
##  PARAGUAY       :  38   1631   :  10   Caballito    : 258   Median :11.000  
##  HUMBOLDT       :  34   2256   :  10   Villa Devoto : 195   Mean   : 9.795  
##  TRIUNVIRATO AV.:  32   332    :  10   Flores       : 193   3rd Qu.:13.000  
##  BONIFACIO, JOSE:  31   444    :  10   Saavedra     : 174   Max.   :15.000  
##  (Other)        :5735   (Other):5850   (Other)      :4576   NA's   :127     
##  fecha_registro      
##  Min.   :2017-09-05  
##  1st Qu.:2018-05-11  
##  Median :2018-11-29  
##  Mean   :2018-12-01  
##  3rd Qu.:2019-07-15  
##  Max.   :2019-12-30  
##  NA's   :7

Observamos que el dataset va de Mayo 2017 a Diciembre 2019. Adicionalmente detectamos que en Latitud y Longitud tenemos 127 NA’s que debemos corregir

library(ggmap)
library(sf)
bbox <- make_bbox(obras_registradas$Lon, obras_registradas$Lat)
mapa_CABA <- get_stamenmap(bbox = bbox, zoom=12)
## Source : http://tile.stamen.com/terrain/12/1381/2467.png
## Source : http://tile.stamen.com/terrain/12/1382/2467.png
## Source : http://tile.stamen.com/terrain/12/1383/2467.png
## Source : http://tile.stamen.com/terrain/12/1384/2467.png
## Source : http://tile.stamen.com/terrain/12/1381/2468.png
## Source : http://tile.stamen.com/terrain/12/1382/2468.png
## Source : http://tile.stamen.com/terrain/12/1383/2468.png
## Source : http://tile.stamen.com/terrain/12/1384/2468.png
## Source : http://tile.stamen.com/terrain/12/1381/2469.png
## Source : http://tile.stamen.com/terrain/12/1382/2469.png
## Source : http://tile.stamen.com/terrain/12/1383/2469.png
## Source : http://tile.stamen.com/terrain/12/1384/2469.png
obras_registradas <- filter(obras_registradas, !is.na(Lon))
summary(obras_registradas)
##     Seccion        Manzana        Parcela               SMP      
##         :1070          :1085          :1088    - -        :1068  
##  083    : 126   058    :  50   016    : 133   None- -     :  17  
##  065    : 124   017    :  45   004    : 121   033-073-024 :   4  
##  035    : 122   032    :  45   011    : 121   037-025-016c:   4  
##  037    : 120   007    :  44   003    : 119   042-041-022 :   4  
##  043    : 118   020    :  44   015    : 112   067-034-007 :   4  
##  (Other):4220   (Other):4587   (Other):4206   (Other)     :4799  
##        Expediente                      Nomenclacion.par  Fecha.de.registro
##  30880890/18:   8                              :1069    2019-12-30:  97   
##  18184115/17:   7   2019/01/16                 :   9    2018-12-20:  61   
##  18984559/18:   7   17-33-77-3a/5/8/9          :   8    2019-01-02:  54   
##  16079848/19:   6   16-51-101-1a/1b/2/3/4/28/29:   7    2019-07-18:  54   
##  18069223/18:   6   16-43-73-16/17/18          :   6    2019-12-18:  53   
##  30958421/18:   6   17-33-58-22/23             :   6    2019-12-07:  42   
##  (Other)    :5860   (Other)                    :4795    (Other)   :5539   
##               Direccion         Comuna.1    Codigo.postal 
##  A.THOMAS 444      :   8   Comuna 12: 855   Min.   :1001  
##  COCHABAMBA 354/70 :   7   Comuna 11: 668   1st Qu.:1406  
##  ECHEVERRIA 4230/44:   7   Comuna 15: 598   Median :1417  
##  CASTILLO 1659/67  :   6   Comuna 13: 551   Mean   :1379  
##  J.NEWBERY 3431/61 :   6   Comuna 14: 508   3rd Qu.:1428  
##  MONROE 2256/72    :   6   Comuna 10: 427   Max.   :1440  
##  (Other)           :5860   (Other)  :2293   NA's   :24    
##  Codigo.postal.argentino           Tipo.obra    Superficie..m2.   
##          :  24                          :1037   Min.   :     1.0  
##  C1427CCR:   8           Micro Obra     : 469   1st Qu.:   151.8  
##  C1150AAD:   7           Obra Mayor     :1128   Median :   740.3  
##  C1414CTU:   7           Obra Media     :1990   Mean   :  1821.9  
##  C1427EGA:   7           Obra Menor     :1250   3rd Qu.:  1793.4  
##  C1430BTT:   7           SIN INFORMACION:  26   Max.   :160317.0  
##  (Other) :5840                                  NA's   :539       
##                      Direccion.normalizada      Lon              Lat        
##  ALVAREZ THOMAS AV. 444         :   8      Min.   :-58.53   Min.   :-34.69  
##  COCHABAMBA 354                 :   7      1st Qu.:-58.49   1st Qu.:-34.62  
##  ECHEVERRIA 4230                :   7      Median :-58.46   Median :-34.60  
##  CASTILLO 1659                  :   6      Mean   :-58.46   Mean   :-34.60  
##  HUMBOLDT 1925                  :   6      3rd Qu.:-58.43   3rd Qu.:-34.58  
##  LEMOS, JUAN GREGORIO, GRAL. 332:   6      Max.   :-58.34   Max.   :-34.54  
##  (Other)                        :5860                                       
##                         Calle          Altura               Barrio    
##  CORDOBA AV.               :  44   1055   :  11   Palermo      : 354  
##  PARAGUAY                  :  38   1631   :  10   Villa Urquiza: 277  
##  HUMBOLDT                  :  34   2256   :  10   Caballito    : 258  
##  TRIUNVIRATO AV.           :  32   332    :  10   Villa Devoto : 195  
##  BONIFACIO, JOSE           :  31   444    :  10   Flores       : 193  
##  ALBERDI, JUAN BAUTISTA AV.:  30   2978   :   9   Saavedra     : 174  
##  (Other)                   :5691   (Other):5840   (Other)      :4449  
##      Comuna       fecha_registro      
##  Min.   : 1.000   Min.   :2017-09-05  
##  1st Qu.: 7.000   1st Qu.:2018-05-11  
##  Median :11.000   Median :2018-12-07  
##  Mean   : 9.795   Mean   :2018-12-04  
##  3rd Qu.:13.000   3rd Qu.:2019-07-18  
##  Max.   :15.000   Max.   :2019-12-30  
##                   NA's   :7

2.Análisis Temporal:Realizar al menos 1 gráfico que les permita analizar la temporalidad de los datos. ¿Detectan algún patrón temporal? ¿A qué puede deberse?

Generamos la variable Tiempo para poder analizar su distribución temporal

obras_registradas <- filter(obras_registradas, !is.na(fecha_registro))
obras_registradas <- obras_registradas %>% 
  mutate(tiempo=today()-fecha_registro)
ggplot(obras_registradas)+
  geom_histogram(aes(x=tiempo))
## Don't know how to automatically pick scale for object of type difftime. Defaulting to continuous.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

A priori no hay una marcada tendencia de crecimiento o decrecimiento. Sí llama la atención algunos alti-bajos recurrentes. Analicemos su distribución temporal para poder tener más detalle

ggplot(obras_registradas %>% 
         group_by(fecha_registro) %>% 
         summarise(cantidad=n()))+
  geom_line(aes(x=fecha_registro, y=cantidad))

Si bien detectamos marcados picos, viéndolo por fecha (por día) es difícil de identificar. Utilicemos una agregación por mes

obras_registradas <- obras_registradas %>% 
  mutate(mes=month(fecha_registro, label=TRUE))
obras_registradas <- obras_registradas %>% 
  mutate(año=year(fecha_registro))
summary(obras_registradas)
##     Seccion        Manzana        Parcela               SMP      
##         :1070          :1085          :1088    - -        :1068  
##  083    : 126   058    :  50   016    : 133   None- -     :  17  
##  065    : 124   017    :  45   004    : 121   033-073-024 :   4  
##  035    : 122   032    :  45   011    : 121   037-025-016c:   4  
##  037    : 120   007    :  44   003    : 119   042-041-022 :   4  
##  043    : 118   020    :  44   015    : 112   067-034-007 :   4  
##  (Other):4213   (Other):4580   (Other):4199   (Other)     :4792  
##        Expediente            Nomenclacion.par  Fecha.de.registro
##  30880890/18:   8                    :1069    2019-12-30:  97   
##  18184115/17:   7   2019/01/16       :   9    2018-12-20:  61   
##  16079848/19:   6   17-33-77-3a/5/8/9:   8    2019-01-02:  54   
##  18069223/18:   6   16-43-73-16/17/18:   6    2019-07-18:  54   
##  30958421/18:   6   17-33-58-22/23   :   6    2019-12-18:  53   
##  10872986/17:   4   17-33-76-11/12/21:   6    2019-12-07:  42   
##  (Other)    :5856   (Other)          :4789    (Other)   :5532   
##              Direccion         Comuna.1    Codigo.postal 
##  A.THOMAS 444     :   8   Comuna 12: 848   Min.   :1001  
##  COCHABAMBA 354/70:   7   Comuna 11: 668   1st Qu.:1406  
##  CASTILLO 1659/67 :   6   Comuna 15: 598   Median :1417  
##  J.NEWBERY 3431/61:   6   Comuna 13: 551   Mean   :1379  
##  MONROE 2256/72   :   6   Comuna 14: 508   3rd Qu.:1428  
##  PARAGUAY 460/76  :   6   Comuna 10: 427   Max.   :1440  
##  (Other)          :5854   (Other)  :2293   NA's   :24    
##  Codigo.postal.argentino           Tipo.obra    Superficie..m2.   
##          :  24                          :1037   Min.   :     1.0  
##  C1427CCR:   8           Micro Obra     : 469   1st Qu.:   151.3  
##  C1150AAD:   7           Obra Mayor     :1121   Median :   738.5  
##  C1414CTU:   7           Obra Media     :1990   Mean   :  1818.2  
##  C1427EGA:   7           Obra Menor     :1250   3rd Qu.:  1788.8  
##  C1431FJU:   7           SIN INFORMACION:  26   Max.   :160317.0  
##  (Other) :5833                                  NA's   :539       
##                      Direccion.normalizada      Lon              Lat        
##  ALVAREZ THOMAS AV. 444         :   8      Min.   :-58.53   Min.   :-34.69  
##  COCHABAMBA 354                 :   7      1st Qu.:-58.49   1st Qu.:-34.62  
##  CASTILLO 1659                  :   6      Median :-58.46   Median :-34.60  
##  HUMBOLDT 1925                  :   6      Mean   :-58.46   Mean   :-34.60  
##  LEMOS, JUAN GREGORIO, GRAL. 332:   6      3rd Qu.:-58.43   3rd Qu.:-34.58  
##  MONROE 2256                    :   6      Max.   :-58.34   Max.   :-34.54  
##  (Other)                        :5854                                       
##                         Calle          Altura               Barrio    
##  CORDOBA AV.               :  44   1055   :  11   Palermo      : 354  
##  PARAGUAY                  :  38   1631   :  10   Villa Urquiza: 270  
##  HUMBOLDT                  :  34   2256   :  10   Caballito    : 258  
##  TRIUNVIRATO AV.           :  32   332    :  10   Villa Devoto : 195  
##  BONIFACIO, JOSE           :  31   444    :  10   Flores       : 193  
##  ALBERDI, JUAN BAUTISTA AV.:  30   2978   :   9   Saavedra     : 174  
##  (Other)                   :5684   (Other):5833   (Other)      :4449  
##      Comuna       fecha_registro          tiempo              mes      
##  Min.   : 1.000   Min.   :2017-09-05   Length:5893       nov    : 775  
##  1st Qu.: 7.000   1st Qu.:2018-05-11   Class :difftime   dic    : 763  
##  Median :11.000   Median :2018-12-07   Mode  :numeric    oct    : 762  
##  Mean   : 9.792   Mean   :2018-12-04                     jul    : 465  
##  3rd Qu.:13.000   3rd Qu.:2019-07-18                     sep    : 463  
##  Max.   :15.000   Max.   :2019-12-30                     jun    : 421  
##                                                          (Other):2244  
##       año      
##  Min.   :2017  
##  1st Qu.:2018  
##  Median :2018  
##  Mean   :2018  
##  3rd Qu.:2019  
##  Max.   :2019  
## 
obras_registradas <- obras_registradas %>% 
  mutate(año=as.factor(año))
ggplot(obras_registradas %>% 
         filter(año==2017) %>% 
         group_by(mes, Tipo.obra) %>% 
        summarise(cantidad=n()))+
  geom_line(aes(x=mes, y=cantidad, color=Tipo.obra, group=Tipo.obra))+
  geom_point(aes(x=mes, y=cantidad, color=Tipo.obra))+
  geom_text(aes(x=mes, y=cantidad+10, label=cantidad, color=Tipo.obra), size=2)+
  labs(title = "Obras registradas en la CABA durante 2017", 
       subtitle  = "Fuentes: BA DATA")
## `summarise()` has grouped output by 'mes'. You can override using the `.groups` argument.

En 2017 vemos un valor elevado en Octubre con 109 obras registradas de “obra media” pero nada muy significativo

ggplot(obras_registradas %>% 
         filter(año==2018) %>% 
         group_by(mes, Tipo.obra) %>% 
        summarise(cantidad=n()))+
  geom_line(aes(x=mes, y=cantidad, color=Tipo.obra, group=Tipo.obra))+
  geom_point(aes(x=mes, y=cantidad, color=Tipo.obra))+
  geom_text(aes(x=mes, y=cantidad+10, label=cantidad, color=Tipo.obra), size=2)+
  labs(title = "Obras registradas en la CABA durante 2018", 
       subtitle  = "Fuentes: BA DATA")
## `summarise()` has grouped output by 'mes'. You can override using the `.groups` argument.

Por otro lado en 2018 el comportamiento es más errático de “Obra Media” teniendo picos en Abril y Noviembre. Por otro lado el tipo de obra “Micro Obra” tuvo un comportamiento ascendente a partir de septiembre 2018

ggplot(obras_registradas %>% 
         filter(año==2019) %>% 
         group_by(mes, Tipo.obra) %>% 
        summarise(cantidad=n()))+
  geom_line(aes(x=mes, y=cantidad, color=Tipo.obra, group=Tipo.obra))+
  geom_point(aes(x=mes, y=cantidad, color=Tipo.obra))+
  geom_text(aes(x=mes, y=cantidad+10, label=cantidad, color=Tipo.obra), size=2)+
  labs(title = "Obras registradas en la CABA durante 2019", 
       subtitle  = "Fuentes: BA DATA")
## `summarise()` has grouped output by 'mes'. You can override using the `.groups` argument.

El año 2019 es más marcado, teniendo un pico de 219 registros de Obra Mayor en Julio y registros de 250/300 obras que llamativamente poseen un valor NULL en Tipo de Obra

Por otro lado, analicemos si el día de la semana afecta en algo a la salida de las Obras Registradas en CABA

obras_registradas <- obras_registradas %>% 
  mutate(dia_semana=wday(fecha_registro, label=TRUE, abbr=FALSE))
ggplot(obras_registradas)+
  geom_bar(aes(x=dia_semana, fill = Tipo.obra))+
  labs(title = "Obras registradas según día de la semana", 
       subtitle  = "Fuentes: BA DATA")

Podemos observar como los días de fin de semana (casi) no se encuentran registros. Probablemente esto se deba a que los expedientes tramitados por el Gobierno de la Ciudad de Buenos Aires, específicamente la Dirección General de Obra y Catastro, no tramitan expedientes los días sábados o domingos, excepto algunos casos particulares. Adicionalmente, miércoles y jueves son los días de mayor cantidad de obras registradas.

3.Análisis Espacial:Analizar la distribución espacial de los datos a partir de al menos 1 mapa de densidad que muestre donde se concentran la mayor cantidad de observaciones. Comparar la densidad de los datos en el tiempo (facetar). ¿Los patrones espaciales de los datos elegidos se mantienen o varían en el tiempo?

summary(obras_registradas)
##     Seccion        Manzana        Parcela               SMP      
##         :1070          :1085          :1088    - -        :1068  
##  083    : 126   058    :  50   016    : 133   None- -     :  17  
##  065    : 124   017    :  45   004    : 121   033-073-024 :   4  
##  035    : 122   032    :  45   011    : 121   037-025-016c:   4  
##  037    : 120   007    :  44   003    : 119   042-041-022 :   4  
##  043    : 118   020    :  44   015    : 112   067-034-007 :   4  
##  (Other):4213   (Other):4580   (Other):4199   (Other)     :4792  
##        Expediente            Nomenclacion.par  Fecha.de.registro
##  30880890/18:   8                    :1069    2019-12-30:  97   
##  18184115/17:   7   2019/01/16       :   9    2018-12-20:  61   
##  16079848/19:   6   17-33-77-3a/5/8/9:   8    2019-01-02:  54   
##  18069223/18:   6   16-43-73-16/17/18:   6    2019-07-18:  54   
##  30958421/18:   6   17-33-58-22/23   :   6    2019-12-18:  53   
##  10872986/17:   4   17-33-76-11/12/21:   6    2019-12-07:  42   
##  (Other)    :5856   (Other)          :4789    (Other)   :5532   
##              Direccion         Comuna.1    Codigo.postal 
##  A.THOMAS 444     :   8   Comuna 12: 848   Min.   :1001  
##  COCHABAMBA 354/70:   7   Comuna 11: 668   1st Qu.:1406  
##  CASTILLO 1659/67 :   6   Comuna 15: 598   Median :1417  
##  J.NEWBERY 3431/61:   6   Comuna 13: 551   Mean   :1379  
##  MONROE 2256/72   :   6   Comuna 14: 508   3rd Qu.:1428  
##  PARAGUAY 460/76  :   6   Comuna 10: 427   Max.   :1440  
##  (Other)          :5854   (Other)  :2293   NA's   :24    
##  Codigo.postal.argentino           Tipo.obra    Superficie..m2.   
##          :  24                          :1037   Min.   :     1.0  
##  C1427CCR:   8           Micro Obra     : 469   1st Qu.:   151.3  
##  C1150AAD:   7           Obra Mayor     :1121   Median :   738.5  
##  C1414CTU:   7           Obra Media     :1990   Mean   :  1818.2  
##  C1427EGA:   7           Obra Menor     :1250   3rd Qu.:  1788.8  
##  C1431FJU:   7           SIN INFORMACION:  26   Max.   :160317.0  
##  (Other) :5833                                  NA's   :539       
##                      Direccion.normalizada      Lon              Lat        
##  ALVAREZ THOMAS AV. 444         :   8      Min.   :-58.53   Min.   :-34.69  
##  COCHABAMBA 354                 :   7      1st Qu.:-58.49   1st Qu.:-34.62  
##  CASTILLO 1659                  :   6      Median :-58.46   Median :-34.60  
##  HUMBOLDT 1925                  :   6      Mean   :-58.46   Mean   :-34.60  
##  LEMOS, JUAN GREGORIO, GRAL. 332:   6      3rd Qu.:-58.43   3rd Qu.:-34.58  
##  MONROE 2256                    :   6      Max.   :-58.34   Max.   :-34.54  
##  (Other)                        :5854                                       
##                         Calle          Altura               Barrio    
##  CORDOBA AV.               :  44   1055   :  11   Palermo      : 354  
##  PARAGUAY                  :  38   1631   :  10   Villa Urquiza: 270  
##  HUMBOLDT                  :  34   2256   :  10   Caballito    : 258  
##  TRIUNVIRATO AV.           :  32   332    :  10   Villa Devoto : 195  
##  BONIFACIO, JOSE           :  31   444    :  10   Flores       : 193  
##  ALBERDI, JUAN BAUTISTA AV.:  30   2978   :   9   Saavedra     : 174  
##  (Other)                   :5684   (Other):5833   (Other)      :4449  
##      Comuna       fecha_registro          tiempo              mes      
##  Min.   : 1.000   Min.   :2017-09-05   Length:5893       nov    : 775  
##  1st Qu.: 7.000   1st Qu.:2018-05-11   Class :difftime   dic    : 763  
##  Median :11.000   Median :2018-12-07   Mode  :numeric    oct    : 762  
##  Mean   : 9.792   Mean   :2018-12-04                     jul    : 465  
##  3rd Qu.:13.000   3rd Qu.:2019-07-18                     sep    : 463  
##  Max.   :15.000   Max.   :2019-12-30                     jun    : 421  
##                                                          (Other):2244  
##    año           dia_semana  
##  2017: 740   domingo  :  83  
##  2018:2397   lunes    : 885  
##  2019:2756   martes   :1083  
##              miércoles:1366  
##              jueves   :1329  
##              viernes  :1078  
##              sábado   :  69
ggmap(mapa_CABA)+
  geom_point(data=obras_registradas, aes(x=Lon, y=Lat, color=Tipo.obra))

ggmap(mapa_CABA)+
  geom_point(data=obras_registradas, aes(x=Lon, y=Lat, color=Tipo.obra))+
   facet_wrap(~Tipo.obra)+
  labs(title = "Obras registradas en la CABA según Tipo de Obra", 
       subtitle  = "Fuentes: BA DATA")

Si bien la distribución por Tipo de Obra es bastante similar, podemos observar que las Obras menores van disminuyendo de Oeste a Este en la Ciudad de Buenos Aires.

ggmap(mapa_CABA)+
  geom_point(data=obras_registradas, aes(x=Lon, y=Lat, color=Tipo.obra))+
   facet_wrap(~año)+
  labs(title = "Obras registradas en la CABA (2017 - 2019)", 
       subtitle  = "Fuentes: BA DATA")

Lógicamente al tener datos del 2017 sólo a partir de Mayo es el año con menor cantidad de Obras Registradas. Por otro lado, lamentablemente, en 2019 vemos la aparición de muchas obras sin Tipo de Obra, es decir, un valor NULL o Missing

ggmap(mapa_CABA)+
  geom_bin2d(data=obras_registradas, aes(x=Lon, y=Lat), alpha=0.8, bins=50)+
  scale_fill_viridis_c()+
  facet_wrap(~año)

De manera agregada, podemos ver un crecimiento de Obras Registradas en la zona de Colegiales.