This report analyzes affordable housing production data. The data are from NYC Open Data and are provided by the New York City Department of Housing Preservation and Development (HPD).
# Import the NYC affordable housing data
housing <- readr::read_csv("affordable_housing.csv",show_col_types = TRUE)
## Rows: 9250 Columns: 41
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (12): Project Name, Project Start Date, Project Completion Date, Number,...
## dbl (28): Project ID, Building ID, Postcode, BBL, BIN, Council District, Cen...
## num (1): Total Units
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Display the first six rows of the dataset.
head(housing)
## # A tibble: 6 × 41
## `Project ID` `Project Name` `Project Start Date` Project Completion D…¹
## <dbl> <chr> <chr> <chr>
## 1 75917 HOUSING PLUS. 729 VA… 03/31/2026 <NA>
## 2 76580 1692/1702/1706 UNION… 03/31/2026 03/31/2026
## 3 76580 1692/1702/1706 UNION… 03/31/2026 03/31/2026
## 4 77723 431 CONCORD AVENUE 03/31/2026 <NA>
## 5 78451 CONFIDENTIAL 03/31/2026 <NA>
## 6 77166 BERGEN WYCKOFF 03/30/2026 <NA>
## # ℹ abbreviated name: ¹`Project Completion Date`
## # ℹ 37 more variables: `Building ID` <dbl>, Number <chr>, Street <chr>,
## # Borough <chr>, Postcode <dbl>, BBL <dbl>, BIN <dbl>,
## # `Community Board` <chr>, `Council District` <dbl>, `Census Tract` <dbl>,
## # `NTA - Neighborhood Tabulation Area` <chr>, Latitude <dbl>,
## # Longitude <dbl>, `Latitude (Internal)` <dbl>, `Longitude (Internal)` <dbl>,
## # `Building Completion Date` <chr>, `Reporting Construction Type` <chr>, …
# Check the number of rows and columns
dim(housing)
## [1] 9250 41
# Review the Column Names
names(housing)
## [1] "Project ID" "Project Name"
## [3] "Project Start Date" "Project Completion Date"
## [5] "Building ID" "Number"
## [7] "Street" "Borough"
## [9] "Postcode" "BBL"
## [11] "BIN" "Community Board"
## [13] "Council District" "Census Tract"
## [15] "NTA - Neighborhood Tabulation Area" "Latitude"
## [17] "Longitude" "Latitude (Internal)"
## [19] "Longitude (Internal)" "Building Completion Date"
## [21] "Reporting Construction Type" "Extended Affordability Only"
## [23] "Prevailing Wage Status" "Extremely Low Income Units"
## [25] "Very Low Income Units" "Low Income Units"
## [27] "Moderate Income Units" "Middle Income Units"
## [29] "Other Income Units" "Studio Units"
## [31] "1-BR Units" "2-BR Units"
## [33] "3-BR Units" "4-BR Units"
## [35] "5-BR Units" "6-BR+ Units"
## [37] "Unknown-BR Units" "Counted Rental Units"
## [39] "Counted Homeownership Units" "All Counted Units"
## [41] "Total Units"
# Calculate the mean Total Units
mean(housing$`Total Units`, na.rm = TRUE)
## [1] 47.1213
# Calculate the median Total Units
median(housing$`Total Units`, na.rm = TRUE)
## [1] 12
# Calculate the standard deviation of Total Units.
sd(housing$`Total Units`, na.rm = TRUE)
## [1] 92.66828
# Bedroom Units
# Calculate summary statistics for One-Bedroom Units
summary(housing$`1-BR Units`)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NAs
## 1.00 2.00 6.00 19.13 21.00 312.00 3313
# Calculate summary statistics for Two-Bedroom Units
summary(housing$`2-BR Units`)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NAs
## 1.00 2.00 7.00 17.65 18.00 305.00 3391
# Calculate summary statistics for three-bedroom units
summary(housing$`3-BR Units`)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NAs
## 1.00 1.00 4.00 10.41 11.00 193.00 5917
New York City has five boroughs: Bronx, Brooklyn, Manhattan, Queens, and Staten Island.
# Count the number of buildings in each borough
table(housing$Borough)
##
## Bronx Brooklyn Manhattan Queens Staten Island
## 2502 3593 1449 1268 438
The results show that Manhattan has the highest average number of total housing units per building, while Staten Island has the lowest average. The bar chart below provides a visual comparison of the five boroughs.
# Calculate the average Total Affordable Housing Units by Borough.
borough_summary <- housing |> dplyr::group_by(Borough) |> dplyr::summarise(Average_Total_Units = mean(`Total Units`, na.rm = TRUE))
borough_summary
## # A tibble: 5 × 2
## Borough Average_Total_Units
## <chr> <dbl>
## 1 Bronx 47.1
## 2 Brooklyn 39.5
## 3 Manhattan 73.1
## 4 Queens 49.8
## 5 Staten Island 15.8
# Create a bar chart comparing average total Affordable Housing Units by borough
ggplot2::ggplot(borough_summary, ggplot2::aes(Borough, Average_Total_Units)) + ggplot2::geom_col() +
ggplot2::labs(title = "Average Total Affordable Housing Units by Borough")
New York City Department of Housing Preservation and Development (HPD). “Affordable Housing Production by Building”. NYC Open Data. https://data.cityofnewyork.us/Housing-Development/Affordable-Housing-Production-by-Building/hg8x-zxpr/about_data