RShiny App to Visualize Hygiene Conditions
This blog presents an RShiny application to visualize trends from food safety inspections and better understand hygiene factors
In this blog I analyze and present trends from inspections of various facility types in the city of Chicago during the years of 2010-2019 by Chicago Department of Public Health's Food Protection Program. The raw data set can be found here. The data set provides users with information pertinent to the food safety inspections such as the result of the inspection (Pass/Fail etc), name of the facility inspected inter alia.
QUESTIONS OF INTEREST:
Herein this article the frequency distribution of various factors and their dependence on other competitive and/or aiding factors is analyzed.
The metadata information of the data set is depicted in the below table. The description for the metadata is interpreted from examining the data set and shown below:
|Inspection.ID||A unique number assigned to a specific facility under inspection||Number|
|DBA.Name||Name of the facility||String|
|AKA.Name||Short name of the facility||String|
|Lincense..||A unique number assigned to each faciltity||Number|
|Facility.Type||Denotes the type of the facility||String|
|Risk||Denotes the risk level of a facility||String|
|Address||Denotes the address of the facility||String|
|City||Name of the city the facility is in||String|
|State||Name of the state the facility is in||String|
|Zip||Denotes the zip code of the facility||Number|
|Inspection.Date||The date when the facility was inspected||String|
|Inspection.Type||Denotes if the facility was inspected first time or re-inspected||String|
|Results||Denotes if the inspection resulted in a Pass, Fail, etc||String|
|Violations||Describes the reasons for the results and any violations||String|
|Latitude||Denotes the Latitude of the facility||Number|
|Longitude||Denotes the Longitude of the facility||Number|
|Location||Denotes the latitude and longitude position||String|
|Year||Denotes the year of inspection||Number|
A variety of facility types have been inspected. A total of 487 facility types were inspected. However, the facility types of 'Restaurant', 'Grocery Store' and 'School' comprise 85% of the sample size.
FREQUENCY DISTRIBUTION OF FACILITIES:
The frequency distribution of the facility types is studied. The R Shiny app presents the distribution of all facility types and the top 10 facilities per frequency count subject to constraints on the parameter of 'Risk', 'Year' and 'Results'. Such a plot is quite useful to understand how the facility types have evolved in performance each year. The top 10 facility types and their respective counts are shown in Table 1.
RISK PROPORTION OF FACILITY TYPES:
Although a high fraction of facility types have a 'Pass' result from the inspection agency, many of them have higher risks associated. Quite surprisingly, a large fraction of each facility type suffer from a 'High Risk' score. This is also represented in Table 2. This underscores the importance and necessity of a 'Hygiene' kind of a score. It is noted that such a score in this scenario would have not been strongly correlated with the 'Results' issued by the agency but is nevertheless very critical for the general public health.
FREQUENCY DISTRIBUTION OF THE LOCATION (LATITUDE, LONGITUDE):
Finally, the frequency distribution of the facility type is plotted as a function of the latitude and the longitude of the facility type. Such a plot helps one to identify specific locations in the city with the observed 'Results' in general.
The code for the project is available here.
The RShiny app can be found here.