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 from the CSV file.
housing <- readr::read_csv("affordable_housing.csv",show_col_types = FALSE)
# 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"
# Summary Statistics for 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
# Rental and Homeownership Units
# Counted Rental Units
summary(housing$`Counted Rental Units`)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.     NAs 
##    1.00    5.00   13.00   37.55   41.00  917.00    2526
# Counted Homeownership Units
summary(housing$`Counted Homeownership Units`)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.     NAs 
##    1.00    1.00    1.00   22.87    2.00  489.00    6609
# 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. # Housing Units by Borough

# Count the number of buildings in each borough
table(housing$Borough)
## 
##         Bronx      Brooklyn     Manhattan        Queens Staten Island 
##          2502          3593          1449          1268           438
# Calculate the average Total 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

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.

# Create a bar chart comparing average total units by borough
ggplot2::ggplot(borough_summary,ggplot2::aes(x = Borough, y = Average_Total_Units)) + ggplot2::geom_col() + ggplot2::labs( title = "Average Total Housing Units by Borough", x = "Borough", y = "Average Total Units")

Data Source

New York City Department of Housing Preservation and Development (HPD). “Affordable Housing Production by Building”. NYC Open Data.