#Trabajamos sobre el dataset inicial#

#Trabajamos sobre las fechas#

#Restringimos mediante una intersección espacial#

#Separamos las coordenadas para poder trabajar bien#

## Warning in brewer.pal(n = 15, name = "OrRd"): n too large, allowed maximum for palette OrRd is 9
## Returning the palette you asked for with that many colors
## Warning: Found less unique colors (9) than unique zcol values (16)! 
## Interpolating color vector to match number of zcol values.
mapview(Monoambientes_en_oferta, legend =TRUE ,zcol = "cantidad", at = quantile(Monoambientes_en_oferta$cantidad, na.rm= TRUE, prob = seq(0,1,1/8))) + mapview(bp)

#Ahora vamos con dos ambientes#

mapview(Valor_3_Ambientes, legend =TRUE, col.regions = my.palette, legend.pos = "Botright" ,zcol = "price", at = quantile(Valor_3_Ambientes$price, na.rm= TRUE, prob = seq(0,1,1/15))) + mapview(bp)
## Warning: Found less unique colors (9) than unique zcol values (16)! 
## Interpolating color vector to match number of zcol values.
mapview(Dos_ambientes_en_oferta, legend =TRUE ,zcol = "cantidad", at = quantile(Dos_ambientes_en_oferta$cantidad, na.rm= TRUE, prob = seq(0,1,1/12))) + mapview(bp)

#Ahora vamos con 3 ambientes#

mapview(Valor_3_Ambientes, legend =TRUE, col.regions = my.palette, legend.pos = "Botright" ,zcol = "price", at = quantile(Valor_3_Ambientes$price, na.rm= TRUE, prob = seq(0,1,1/15))) + mapview(bp)
## Warning: Found less unique colors (9) than unique zcol values (16)! 
## Interpolating color vector to match number of zcol values.
mapview(Tres_ambientes_en_oferta, legend =TRUE ,zcol = "cantidad", at = quantile(Tres_ambientes_en_oferta$cantidad, na.rm= TRUE, prob = seq(0,1,1/12))) + mapview(bp)

#Universidades#

ggmap(CABA) +
    geom_density2d(data = Universidades, aes(x = long, y = lat, color = stat(level))) +
    scale_color_viridis_c()

mapview(Universidades)
mapview(Universidades, legend =TRUE ,zcol = "cantidad") + mapview(bp)

#Analisis Censal#

ggplot() +
  geom_sf(data = barrios) +
  geom_sf(data=radiosCensales %>% filter(!is.na(nbi)), aes(fill=nbi), color=NA) +
  scale_fill_viridis_c() +
  theme_void() +
  labs(title = "Hogares con NBI por manzana", fill = "NBI")

mapview(radiosCensales, legend =TRUE, col.regions = my.palette, legend.pos = "Botright" ,zcol = "nbi", at = quantile(radiosCensales$nbi, na.rm= TRUE, prob = seq(0,1,1/11))) + mapview(bp)
## Warning: Found less unique colors (9) than unique zcol values (12)! 
## Interpolating color vector to match number of zcol values.
summary(radiosCensales$nbi)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max.     NA's 
## 0.000000 0.006056 0.018843 0.061514 0.075884 0.888889        2
ggplot() +
  geom_sf(data = barrios) +
  geom_sf(data=radiosCensales_P %>% filter(!is.na(nbi)), aes(fill=nbi), color=NA) +
  scale_fill_viridis_c() +
  theme_void() +
  labs(title = "Hogares con NBI por manzana", fill = "NBI")

ggplot() +
  geom_sf(data = airbnb_con_barrios, aes(fill=cantidad)) +
  geom_sf_text(data=airbnb_con_barrios, aes(label = COMUNA), size=2.5, colour = "black") +
    labs(title = "Oferta de Airbnb por barrio",
         subtitle = "Propiedades publicadas",
         fill = "Cantidad",
         caption= "Fuente: Airbnb 2021",
         y="",
         x="") +
  scale_fill_gradient(low="khaki2", high="deeppink4")
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

ggplot() +
  geom_sf(data = airbnb_con_barrios, aes(fill=(cantidad/AREA)*10000)) +
  geom_sf_text(data=airbnb_con_barrios, aes(label = COMUNA), size=2.5, colour = "black")+
    labs(title = "Oferta de Airbnb por barrio",
         subtitle = "Densidad de propiedades publicadas",
         fill = "Cantidad por ha",
         caption= "Fuente: Airbnb 2021",
         y="",
         x="") +
  scale_fill_gradient(low="khaki2", high="deeppink4")
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

airbnb3 %>%
  tail(154) %>%
  ggplot( aes(x=month, y=cantidad)) +
    geom_line( color="yellow", size = 2 )  +
    theme_classic() +
    ggtitle("Cantidad de nuevos hospedadores en Airbnb") + labs (x= "Fecha")
## Warning: Removed 1 row(s) containing missing values (geom_path).

#Consumo cultural#