insp_prep_data | R Documentation |
insp_prep_data()
prepares data from the inspections team for display
as an HTML table. It selects, transforms, orders, and sorts the five columns
needed for display and outputs a visualization-ready dataset.
insp_prep_data(.data)
.data |
A data frame containing the inspections data |
insp_prep_data()
chains together a number of operations on the input
data.
First, columns are selected as defined in the Details of
insp_cols_exist()
;
if multiple columns match this selection, they are
coalesced
.
Second, columns are transformed according to type and assigned a standard
name. Visit date and closure date are assigned to dt_visit
and dt_closed
,
respecively, and converted to the ISO 8601 standard (see
convert_to_date()
,
insp_cast_chr_date()
, and
insp_replace_year_long()
). Name and address columns are assigned to nm_business
and
addr_business
, respectively, and converted to character with
extra whitespace removed. The number of violations is assigned to
n_violations
and converted to integer.
Third, rows missing a business name or number of violations (nm_business
or n_violations
) are removed from the dataset. Entries without names are
not easily identifiable, and the primary purpose of the table is to display
violations.
Fourth, columns are reordered for ease of viewing, and unnecessary columns
(any not listed above) are dropped. The ordering is n_violations
,
nm_business
, addr_business
, dt_visit
, and dt_closed
.
Last, rows are arranged by column from left to right (first by
n_violations
, then by nm_business
, and so on). n_violations
,
dt_visit
, and dt_closed
are arranged in descending order (most violations
and most recent dates first); nm_business
and addr_business
are arranged
in ascending order (aka alphabetically).
The processed data frame
Other functions in the inspections data pipeline (
insp_load_data()
,
insp_create_table()
,
insp_save_table()
,
insp_archive_table()
) and the wrapper for the full workflow
(
insp_table_pipeline()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.