Interactive map

This map is an information with the new department on sale in a Santiago area. I show important content such as price per m2, bicycle rack, green arean, thermopanel, gym and so on.

Lecure of the database

## Parsed with column specification:
## cols(
##   .default = col_character(),
##   id = col_integer(),
##   PisosTotales = col_integer(),
##   Ascensores = col_integer(),
##   Bodega = col_integer(),
##   Estacionamiento = col_integer(),
##   precioDeptoUF = col_double(),
##   precioTotalDeptoUF = col_double(),
##   PrecioDeptoCLP = col_integer(),
##   m2Depto = col_double(),
##   m2Terraza = col_double(),
##   m2Totales = col_double(),
##   `UF-m2` = col_double(),
##   `UF-m2SinEstacionamiento` = col_double(),
##   pie = col_integer(),
##   dormitorios = col_integer(),
##   banos = col_integer(),
##   y = col_double(),
##   x = col_double(),
##   distanciaHypermercado = col_integer(),
##   bank = col_integer()
##   # ... with 19 more columns
## )
## See spec(...) for full column specifications.

Important considerations to data frame

library(leaflet)
## Warning: package 'leaflet' was built under R version 3.4.4
library(htmltools)
names <- c("Nombre","precioTotalDeptoUF","fechaEntrega","Termopanel","AreaVerde","Gimnasio",
           "Piscina","Bicicletero","y","x","bank","bus_station","convenience_store",
           "dentist","doctor","gas_station","park","restaurant","school","shopping_mall",
           "store","subway_station","university","church")
df_total <- subset(deptos_nuevos, select = names)

Mean price per m2

df_total_promedio <- aggregate(x = df_total[c("precioTotalDeptoUF")],
                          FUN = mean,
                          by = list(df_total$Nombre), 
                          na.rm=T)
colnames(df_total_promedio) <- c("Nombre","precioTotalDeptoUF")
df_distancias <- df_total[!duplicated(df_total[,c("Nombre")]),]

Content to the map

labs <- lapply(seq(nrow(df_distancias)), function(i) {
  paste0( '<p>', paste("<B>Name:</B>",df_distancias[i, "Nombre"]), '<p></p>', 
          paste("<B>Date of delivery:</B>",df_distancias[i, "fechaEntrega"]),'</p><p>',
          paste("<B>Price (UF):</B>",df_distancias[i, "precioTotalDeptoUF"]),'</p><p>',
          paste("<B>Gym:</B>",df_distancias[i, "Gimnasio"]),'</p><p>', 
          paste("<B>Swimming pool:</B>",df_distancias[i, "Piscina"]),'</p><p>', 
          paste("<B>Distance to the subway:</B>",df_distancias[i, "subway_station"]," m"), '</p>' ) 
})

Interactive map

df_distancias %>% 
  leaflet() %>%
  addTiles() %>%
  addMarkers(~x, ~y,clusterOptions = markerClusterOptions(),
             label = lapply(labs, HTML))