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-22


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")

Data Cleaning

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

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

Interactive Leaflet Map

leaflet(data_clean) %>%
  addProviderTiles(providers$OpenStreetMap) %>%
  setView(
    lng = mean(data_clean$lon, na.rm = TRUE),
    lat = mean(data_clean$lat, na.rm = TRUE),
    zoom = 10
  ) %>%
  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