Overview

This webpage presents an interactive map of real estate listings in Buenos Aires using the Leaflet library in R.

Dataset source: Kaggle Buenos Aires Real Estate dataset.

Created on: 2026-04-20


Load Required Libraries


Load Dataset

Ensure the CSV file is in the same folder as this R Markdown file.

data <- read_csv("buenos-aires-real-estate.csv")

Inspect Data Structure

glimpse(data)
## Rows: 146,660
## Columns: 19
## $ start_date      <date> 2019-10-17, 2019-10-17, 2019-10-17, 2019-10-17, 2019-…
## $ end_date        <date> 2019-12-23, 2019-11-21, 2019-11-01, 2019-12-23, 2020-…
## $ created_on      <date> 2019-10-17, 2019-10-17, 2019-10-17, 2019-10-17, 2019-…
## $ lat             <dbl> -34.60588, -34.62406, -34.59357, -34.58129, -34.91419,…
## $ lon             <dbl> -58.38495, -58.41211, -58.42747, -58.43675, -57.93822,…
## $ l1              <chr> "Argentina", "Argentina", "Argentina", "Argentina", "A…
## $ l2              <chr> "Capital Federal", "Capital Federal", "Capital Federal…
## $ l3              <chr> "San Cristobal", "Boedo", "Palermo", "Palermo", "La Pl…
## $ rooms           <dbl> 7, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, …
## $ bedrooms        <dbl> 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ bathrooms       <dbl> 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, …
## $ surface_total   <dbl> 140, 70, 45, 85, 50, 56, 70, 70, 45, 45, 66, 68, 50, 5…
## $ surface_covered <dbl> 140, 58, 45, 50, 35, 56, 70, 70, 37, 37, 49, 59, 44, 3…
## $ price           <dbl> 153000, 159000, 125000, 295000, 40000, 150000, 159500,…
## $ currency        <chr> "USD", "USD", "USD", "USD", "USD", "USD", "USD", "USD"…
## $ title           <chr> "***Venta semipiso centro, ideal hostel*****", "Espect…
## $ description     <chr> "DESCRIPCION DE LA PROPIEDAD: Departamento de 140,65 m…
## $ property_type   <chr> "Departamento", "PH", "PH", "PH", "PH", "PH", "PH", "P…
## $ operation_type  <chr> "Venta", "Venta", "Venta", "Venta", "Venta", "Venta", …

Data Cleaning

Dataset already uses lat and lon, so no renaming is required.

data_clean <- data %>%
  filter(!is.na(lat), !is.na(lon))

Summary Statistics

summary(data_clean)
##    start_date            end_date            created_on        
##  Min.   :2019-01-01   Min.   :2019-01-04   Min.   :2019-01-01  
##  1st Qu.:2019-04-30   1st Qu.:2019-06-30   1st Qu.:2019-04-30  
##  Median :2019-08-01   Median :2019-09-14   Median :2019-08-01  
##  Mean   :2019-08-03   Mean   :3386-09-16   Mean   :2019-08-03  
##  3rd Qu.:2019-11-13   3rd Qu.:2020-01-21   3rd Qu.:2019-11-13  
##  Max.   :2020-01-25   Max.   :9999-12-31   Max.   :2020-01-25  
##                                                                
##       lat              lon               l1                 l2           
##  Min.   :-35.32   Min.   :-180.00   Length:136701      Length:136701     
##  1st Qu.:-34.63   1st Qu.: -58.50   Class :character   Class :character  
##  Median :-34.60   Median : -58.44   Mode  :character   Mode  :character  
##  Mean   :-34.60   Mean   : -58.47                                        
##  3rd Qu.:-34.57   3rd Qu.: -58.41                                        
##  Max.   : 85.05   Max.   : -57.81                                        
##                                                                          
##       l3                rooms          bedrooms        bathrooms     
##  Length:136701      Min.   : 1.00   Min.   : 0.000   Min.   : 1.000  
##  Class :character   1st Qu.: 2.00   1st Qu.: 1.000   1st Qu.: 1.000  
##  Mode  :character   Median : 3.00   Median : 2.000   Median : 1.000  
##                     Mean   : 3.08   Mean   : 1.982   Mean   : 1.581  
##                     3rd Qu.: 4.00   3rd Qu.: 3.000   3rd Qu.: 2.000  
##                     Max.   :35.00   Max.   :15.000   Max.   :14.000  
##                                                      NA's   :5366    
##  surface_total      surface_covered        price            currency        
##  Min.   :    10.0   Min.   :     1.0   Min.   :    5500   Length:136701     
##  1st Qu.:    52.0   1st Qu.:    46.0   1st Qu.:  110000   Class :character  
##  Median :    78.0   Median :    67.0   Median :  165000   Mode  :character  
##  Mean   :   216.8   Mean   :   111.8   Mean   :  235741                     
##  3rd Qu.:   140.0   3rd Qu.:   107.0   3rd Qu.:  260000                     
##  Max.   :193549.0   Max.   :126062.0   Max.   :32434232                     
##  NA's   :19122      NA's   :20142                                           
##     title           description        property_type      operation_type    
##  Length:136701      Length:136701      Length:136701      Length:136701     
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
## 

Interactive Leaflet Map

leaflet(data_clean) %>%
  addProviderTiles(providers$OpenStreetMap) %>%
  addCircleMarkers(
    lng = ~lon,
    lat = ~lat,
    radius = 5,
    stroke = FALSE,
    fillOpacity = 0.7,
    popup = ~paste0(
      "<b>Price:</b> ", 
      if ("price" %in% names(data_clean)) {
        ifelse(is.na(price), "N/A", price)
      } else {
        "N/A"
      },
      "<br>",
      "<b>Property Type:</b> ", 
      if ("property_type" %in% names(data_clean)) {
        ifelse(is.na(property_type), "N/A", property_type)
      } else {
        "N/A"
      }
    )
  )

Notes


Reproducibility

To reproduce this project:

  1. Install required packages:
install.packages(c("rmarkdown", "leaflet", "dplyr", "readr"))
  1. Download dataset from Kaggle:
    https://www.kaggle.com/datasets/dataenthusiast947/buenos-aires-real-estate

  2. Place the CSV file in your working directory

  3. Knit this document to HTML


Session Info

sessionInfo()
## R version 4.5.0 (2025-04-11 ucrt)
## Platform: x86_64-w64-mingw32/x64
## Running under: Windows 11 x64 (build 26100)
## 
## Matrix products: default
##   LAPACK version 3.12.1
## 
## locale:
## [1] LC_COLLATE=English_United States.utf8 
## [2] LC_CTYPE=English_United States.utf8   
## [3] LC_MONETARY=English_United States.utf8
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.utf8    
## 
## time zone: Africa/Nairobi
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] readr_2.2.0   dplyr_1.2.1   leaflet_2.2.3
## 
## loaded via a namespace (and not attached):
##  [1] bit_4.6.0               jsonlite_2.0.0          compiler_4.5.0         
##  [4] crayon_1.5.3            tidyselect_1.2.1        parallel_4.5.0         
##  [7] jquerylib_0.1.4         yaml_2.3.10             fastmap_1.2.0          
## [10] R6_2.6.1                generics_0.1.4          knitr_1.51             
## [13] htmlwidgets_1.6.4       tibble_3.2.1            leaflet.providers_3.0.0
## [16] bslib_0.10.0            pillar_1.11.1           tzdb_0.5.0             
## [19] rlang_1.2.0             cachem_1.1.0            xfun_0.52              
## [22] sass_0.4.10             bit64_4.6.0-1           otel_0.2.0             
## [25] cli_3.6.4               magrittr_2.0.3          crosstalk_1.2.2        
## [28] digest_0.6.37           vroom_1.7.0             rstudioapi_0.18.0      
## [31] hms_1.1.4               lifecycle_1.0.5         vctrs_0.7.3            
## [34] evaluate_1.0.5          glue_1.8.0              rmarkdown_2.31         
## [37] tools_4.5.0             pkgconfig_2.0.3         htmltools_0.5.8.1