The package consists of mi_master_polygons.shp shape file that are used to draw the polygon points across the Michigan state.
These files are generated by using the get_acs function from the tidycensus package. To the county dataset PIHP and CMHSP are added using if else conditions manually and stored in mi_polygons.shp shape file. The scripts can be found in data_retrieval.R script.
When less number of data points are given to the function, then the function joins with its reference dataset at its repective dataset and gets the missing data points and represents them as NA values and its color is filled with grey.
While passing the county names in the dataframe, then then column names should be as following
County level dataset – column name for the name must be “name”
Census tract level dataset – column name for the name must be “name”
County level dataset – column name for the ID must be “countyid”
Census tract level dataset – column name for the ID must be “tractid”
The static map works as a basic map function, whereas by selecting the map type and providing the summarized dataset the function builds a county or PIHP or CMHSP or census tract map.
The following are the arguments that are used by the dynamic map function (map_type, df, col_pallet, addtiles, border_col, legend_label)
### map_type
The comparison is ignores case, hence hence the comparison is of map_types is not case sensitive and the possibe values are tract, county, cmhsp, pihp.
By passing county in the map type argument the function creates a county level map of Michigan
By passing pihp in the map type argument the function creates a PIHP level map of Michigan
By passing cmhsp in the map type argument the function creates a CMHSP level map of Michigan
By passing tract in the map type argument the function creates a tract level map of Michigan
Appropriate summarized dataset must be given in the df argument and the column names must be name, countyid or tractid and summary i.e..name column should contain county or PIHP or CMHSP names, countyid or tractid should contain GEOID of the respective dataset provided and summary column should contain the summarized units.
When names are provided in the dataset then the function uses the name otherwise GEOID is used to map the names from the reference table.
For example:
County level summarized dataset must be provided when County is selected in the map type. PIHP level summarized dataset must be provided when PIHP is selected in the map type and CMHSP level summarized dataset must be provided when CMHSP is selected in the map type.
The dynamic map works similar to the opioid application map. The map can draw county boundaries, PIHP boundaries, CMHSP boundaries and census tract boundaries. When PIHP is selected in the map type and CMHSP data is filtered data the map highlights the PIHP boundaries and draws the selected CMHSP boundaries internally of the PIHP.
The following are the arguments that are used by the dynamic map function (map_type, df, pihp_filter, cmh_filter, col_pallet,addtiles, border_col, bins, legend_label)
### map_type
The comparison is ignores case, hence hence the comparison is of map_types is not case sensitive and the possibe values are tract, county, cmhsp, pihp.
By passing County in the map type argument the function creates a county level map of Michigan
By passing PIHP in the map type argument the function creates a PIHP level map of Michigan
By passing CMHSP in the map type argument the function creates a CMHSP level map of Michigan
By passing tract in the map type argument the function creates a tract level map of Michigan
For example:
County level summarized dataset must be provided when County is selected in the map type. PIHP level summarized dataset must be provided when PIHP is selected in the map type and CMHSP level summarized dataset must be provided when CMHSP is selected in the map type.
For example:
pihp_deaths_filt<-
drug_death %>%
filter(PIHPname == input$select_pihp) %>%
group_by(PIHPname) %>%
summarize( deaths = sum(deaths, na.rm = TRUE), deaths_per_100k = round(mean(deaths_per_100k),digits = 2))
For example:
cmh_deaths_filt<-
drug_death %>%
filter(CMHSP == input$select_cmh) %>%
group_by(CMHSP) %>%
summarize( deaths = sum(deaths, na.rm = TRUE), deaths_per_100k = round(mean(deaths_per_100k),digits = 2))
Choose a color palette of any choice to populate the summarized data.
Viridis is set as the default color pallet
Add a tile layer from a known map provider.
Stamen.TonerLite is set as the default provider tiles.
Fill the border color with your preferred color.
White is set as the default color
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.