The nycrestaurants package provides restaurant inspection results from the New York City Department of Health and Mental Hygiene (DOHMH), downloaded from NYC OpenData on 2026-11-10. DOHMH extracted this version of the data on 2026-11-09, the “record date”.
DOHMH publishes inspections for restaurants and college cafeterias that hold an active permit on the record date, covering up to three years before each establishment’s most recent inspection. Almost all inspections in this extract took place between 2023 and 2026. DOHMH drops establishments that close and violations that are dismissed on adjudication, so the data are not suitable for comparisons across years.
The package contains four objects:
-
nyc_restaurants_sf: one row per establishment, with point geometry in EPSG:2263 (NAD83 / New York Long Island, ftUS). 813 establishments have no coordinates and have empty geometry. -
nyc_inspections_df: one row per inspection. -
nyc_violations_df: one row per violation citation. -
nyc_restaurant_inspections_df: the flat DOHMH source table, with snake_case column names and typed date and numeric columns, one row per violation citation, plus one row for each inspection with no violations and each establishment not yet inspected (with a missinginspection_date). Establishments not yet inspected also appear innyc_restaurants_sf, but not innyc_inspections_df. The flat table haslatitudeandlongitudecolumns in WGS84.
camis is the DOHMH establishment identifier and links all four objects. An inspection is identified by camis, inspection_date, and inspection_type; use these three columns to join nyc_violations_df to nyc_inspections_df. inspection_type combines inspection_program (e.g. “Cycle Inspection”) and inspection_stage (e.g. “Re-inspection”). dba (“doing business as”) is the establishment’s name. score is the inspection score, where lower is better: under 14 points on an initial inspection or re-inspection earns an A; on re-inspection, 14–27 points earns a B and 28 or more a C. An initial inspection scoring 14 or more has no grade (NA) until the re-inspection. grade is A, B, or C, or N (not yet graded), Z (grade pending), or P (grade pending on reopening), and is NA for inspections that do not produce a grade. The logical gradable column marks cycle and pre-permit (operational) initial inspections and re-inspections, the inspections that can produce a letter grade under DOHMH rules. See ?nyc_restaurant_inspections_df for column definitions, grade codes, and caveats.
The package code is MIT licensed. The data are published by the City of New York under the NYC OpenData Terms of Use.
Load
The examples below use the tidyverse and sf. sf is needed to work with nyc_restaurants_sf as a spatial object.
What’s included
nyc_restaurants_sf
#> Simple feature collection with 31488 features and 14 fields (with 813 geometries empty)
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: 914983.6 ymin: 121371.4 xmax: 1067128 ymax: 271859.1
#> Projected CRS: NAD83 / New York Long Island (ftUS)
#> # A tibble: 31,488 × 15
#> camis dba boro building street zipcode phone cuisine community_board
#> * <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <int>
#> 1 30075445 MORRIS … Bronx 1007 MORRI… 10462 7188… Bakery… 211
#> 2 30191841 D.J. RE… Manh… 351 WEST … 10019 2122… Irish 104
#> 3 40355985 FRANK R… Manh… 287 BLEEC… 10014 <NA> <NA> 102
#> 4 40356022 PARK AV… Manh… 75 EAST … 10022 <NA> <NA> 105
#> 5 40356078 I. & L.… Manh… 1500-2N D AVE. <NA> <NA> <NA> NA
#> 6 40356483 WILKEN'… Broo… 7114 AVENU… 11234 7184… Sandwi… 318
#> 7 40356731 TASTE T… Broo… 1839 NOSTR… 11226 7188… Frozen… 317
#> 8 40357217 ASIA PL… Bronx 2300 SOUTH… 10460 7187… Americ… 227
#> 9 40357297 O & G G… Manh… 112 GREEN… 10011 <NA> <NA> 102
#> 10 40359480 1 EAST … Manh… 1 EAST … 10065 2128… Americ… 108
#> # ℹ 31,478 more rows
#> # ℹ 6 more variables: council_district <chr>, census_tract <chr>, bin <chr>,
#> # bbl <chr>, nta <chr>, geometry <POINT [US_survey_foot]>
nyc_inspections_df
#> # A tibble: 92,918 × 10
#> camis inspection_date inspection_type inspection_program inspection_stage
#> <chr> <date> <chr> <chr> <chr>
#> 1 30075445 2023-08-01 Cycle Inspectio… Cycle Inspection Initial Inspect…
#> 2 30075445 2023-08-22 Cycle Inspectio… Cycle Inspection Re-inspection
#> 3 30075445 2024-11-08 Cycle Inspectio… Cycle Inspection Initial Inspect…
#> 4 30075445 2026-02-27 Cycle Inspectio… Cycle Inspection Initial Inspect…
#> 5 30191841 2024-11-20 Cycle Inspectio… Cycle Inspection Initial Inspect…
#> 6 30191841 2025-02-20 Cycle Inspectio… Cycle Inspection Re-inspection
#> 7 30191841 2026-07-30 Cycle Inspectio… Cycle Inspection Initial Inspect…
#> 8 40356483 2023-11-16 Cycle Inspectio… Cycle Inspection Initial Inspect…
#> 9 40356483 2024-04-23 Cycle Inspectio… Cycle Inspection Re-inspection
#> 10 40356483 2025-01-06 Cycle Inspectio… Cycle Inspection Initial Inspect…
#> # ℹ 92,908 more rows
#> # ℹ 5 more variables: action <chr>, score <int>, grade <chr>,
#> # grade_date <date>, gradable <lgl>
nyc_violations_df
#> # A tibble: 288,197 × 6
#> camis inspection_date inspection_type violation_code violation_description
#> <chr> <date> <chr> <chr> <chr>
#> 1 30075445 2023-08-01 Cycle Inspecti… 04L Evidence of mice or …
#> 2 30075445 2023-08-01 Cycle Inspecti… 05H No approved written …
#> 3 30075445 2023-08-01 Cycle Inspecti… 08A Establishment is not…
#> 4 30075445 2023-08-22 Cycle Inspecti… 04L Evidence of mice or …
#> 5 30075445 2023-08-22 Cycle Inspecti… 08A Establishment is not…
#> 6 30075445 2023-08-22 Cycle Inspecti… 08C Pesticide not proper…
#> 7 30075445 2024-11-08 Cycle Inspecti… 06C Food, supplies, or e…
#> 8 30075445 2024-11-08 Cycle Inspecti… 08C Pesticide not proper…
#> 9 30075445 2024-11-08 Cycle Inspecti… 10F Non-food contact sur…
#> 10 30075445 2026-02-27 Cycle Inspecti… 06B Tobacco or electroni…
#> # ℹ 288,187 more rows
#> # ℹ 1 more variable: critical_flag <chr>
glimpse(nyc_restaurant_inspections_df)
#> Rows: 295,292
#> Columns: 26
#> $ camis <chr> "30075445", "30075445", "30075445", "30075445", …
#> $ dba <chr> "MORRIS PARK BAKE SHOP", "MORRIS PARK BAKE SHOP"…
#> $ boro <chr> "Bronx", "Bronx", "Bronx", "Bronx", "Bronx", "Br…
#> $ building <chr> "1007", "1007", "1007", "1007", "1007", "1007", …
#> $ street <chr> "MORRIS PARK AVENUE", "MORRIS PARK AVENUE", "MOR…
#> $ zipcode <chr> "10462", "10462", "10462", "10462", "10462", "10…
#> $ phone <chr> "7188924968", "7188924968", "7188924968", "71889…
#> $ cuisine <chr> "Bakery Products/Desserts", "Bakery Products/Des…
#> $ inspection_date <date> 2023-08-01, 2023-08-01, 2023-08-01, 2023-08-22,…
#> $ action <chr> "Violations were cited in the following area(s).…
#> $ violation_code <chr> "04L", "05H", "08A", "04L", "08A", "08C", "06C",…
#> $ violation_description <chr> "Evidence of mice or live mice in establishment'…
#> $ critical_flag <chr> "Critical", "Critical", "Not Critical", "Critica…
#> $ score <int> 38, 38, 38, 12, 12, 12, 10, 10, 10, 7, 7, 24, 24…
#> $ grade <chr> NA, NA, NA, "A", "A", "A", "A", "A", "A", "A", "…
#> $ grade_date <date> NA, NA, NA, 2023-08-22, 2023-08-22, 2023-08-22,…
#> $ inspection_type <chr> "Cycle Inspection / Initial Inspection", "Cycle …
#> $ gradable <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, …
#> $ latitude <dbl> 40.84823, 40.84823, 40.84823, 40.84823, 40.84823…
#> $ longitude <dbl> -73.85597, -73.85597, -73.85597, -73.85597, -73.…
#> $ community_board <int> 211, 211, 211, 211, 211, 211, 211, 211, 211, 211…
#> $ council_district <chr> "13", "13", "13", "13", "13", "13", "13", "13", …
#> $ census_tract <chr> "025200", "025200", "025200", "025200", "025200"…
#> $ bin <chr> "2045445", "2045445", "2045445", "2045445", "204…
#> $ bbl <chr> "2041270037", "2041270037", "2041270037", "20412…
#> $ nta <chr> "BX37", "BX37", "BX37", "BX37", "BX37", "BX37", …Examples
Most common critical violations
The wording of a violation description can change over time for the same code, so this example takes the most recent description for each code.
nyc_violations_df |>
filter(critical_flag == "Critical") |>
count(violation_code, sort = TRUE) |>
left_join(
nyc_violations_df |>
slice_max(inspection_date, by = violation_code, n = 1, with_ties = FALSE) |>
select(violation_code, violation_description),
by = "violation_code"
) |>
slice_head(n = 10)
#> # A tibble: 10 × 3
#> violation_code n violation_description
#> <chr> <int> <chr>
#> 1 06C 19067 Food, supplies, or equipment not protected from potenti…
#> 2 02G 18917 Cold TCS food item held above 41 °F; smoked or processe…
#> 3 06D 18500 Food contact surface not properly washed, rinsed and sa…
#> 4 02B 15409 Hot TCS food item not held at or above 140 °F.
#> 5 04L 13725 Evidence of mice or live mice in establishment's food o…
#> 6 04N 11439 Filth flies or food/refuse/sewage associated with (FRSA…
#> 7 04A 7676 Food Protection Certificate (FPC) not held by manager o…
#> 8 04H 6231 Raw, cooked or prepared food is adulterated, contaminat…
#> 9 05D 5525 No hand washing facility in or adjacent to toilet room …
#> 10 06F 5360 Wiping cloths not stored clean and dry, or in a sanitiz…Share of A grades by cuisine
This example takes each establishment’s most recent gradable inspection that resulted in an A, B, or C. Other grade codes mark pending or not-yet-graded results.
latest_grades <- nyc_inspections_df |>
filter(gradable, grade %in% c("A", "B", "C")) |>
slice_max(inspection_date, by = camis, n = 1, with_ties = FALSE)
latest_grades |>
left_join(st_drop_geometry(nyc_restaurants_sf), by = "camis") |>
summarize(
n = n(),
pct_a = mean(grade == "A") * 100,
.by = cuisine
) |>
filter(n >= 250) |>
arrange(pct_a)
#> # A tibble: 26 × 3
#> cuisine n pct_a
#> <chr> <int> <dbl>
#> 1 Indian 263 75.3
#> 2 Thai 317 79.2
#> 3 Asian/Asian Fusion 393 80.4
#> 4 Caribbean 675 81.2
#> 5 Chinese 2027 81.7
#> 6 Korean 370 83.0
#> 7 Latin American 1009 83.6
#> 8 Spanish 404 84.4
#> 9 Jewish/Kosher 298 86.6
#> 10 Pizza 1486 88.4
#> # ℹ 16 more rowsMap of most recent grades
Points are sorted so that B and C grades are drawn on top of A grades.
nyc_restaurants_sf |>
inner_join(latest_grades, by = "camis") |>
filter(!st_is_empty(geometry)) |>
arrange(grade) |>
ggplot() +
geom_sf(aes(color = grade), size = 0.2, alpha = 0.6) +
scale_color_manual(values = c(A = "#2c7bb6", B = "#fdae61", C = "#d7191c")) +
guides(color = guide_legend(override.aes = list(size = 3, alpha = 1))) +
labs(
title = "NYC Restaurants by Most Recent Letter Grade",
color = "Grade",
caption = "Data: NYC DOHMH via NYC OpenData"
) +
theme_void()
