| Title: | Create Bivariate Choropleth Maps with 'Leaflet' | 
| Version: | 0.1.0 | 
| Description: | Creates bivariate choropleth maps using 'Leaflet'. This package provides tools for visualizing the relationship between two variables through a color matrix representation on an interactive map. | 
| License: | MIT + file LICENSE | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.3.2 | 
| Imports: | leaflet, dplyr, htmltools, rlang, sf | 
| Suggests: | testthat (≥ 3.0.0), knitr, rmarkdown, tidycensus, tidyr | 
| Config/testthat/edition: | 3 | 
| VignetteBuilder: | knitr | 
| Depends: | R (≥ 3.50) | 
| NeedsCompilation: | no | 
| Packaged: | 2024-12-18 18:50:51 UTC; mduprey | 
| Author: | Michael Duprey [aut, cre], Chris Inkpen [ctb] | 
| Maintainer: | Michael Duprey <mduprey@rti.org> | 
| Repository: | CRAN | 
| Date/Publication: | 2024-12-19 20:40:13 UTC | 
Assign Colors Based on Tertiles
Description
Assign Colors Based on Tertiles
Usage
assign_colors(data, color_matrix)
Arguments
data | 
 A data frame containing tertile columns  | 
color_matrix | 
 A 3x3 matrix of colors  | 
Value
A data frame with added color column
Calculate Tertile Breaks
Description
Calculate Tertile Breaks
Usage
calculate_tertile_breaks(data, variable)
Arguments
data | 
 A data frame  | 
variable | 
 Character string naming the variable  | 
Value
A numeric vector of break points
Calculate Tertiles for Bivariate Variables
Description
Calculate Tertiles for Bivariate Variables
Usage
calculate_tertiles(data, var_1, var_2)
Arguments
data | 
 A data frame containing the variables to analyze  | 
var_1 | 
 Character string naming the first variable  | 
var_2 | 
 Character string naming the second variable  | 
Value
A data frame with added tertile columns
Create Bivariate Choropleth Map
Description
Create Bivariate Choropleth Map
Usage
create_bivariate_map(
  data,
  var_1,
  var_2,
  color_matrix = NULL,
  custom_labels = NULL
)
Arguments
data | 
 A spatial data frame  | 
var_1 | 
 Character string naming first variable  | 
var_2 | 
 Character string naming second variable  | 
color_matrix | 
 Optional custom color matrix  | 
custom_labels | 
 Optional vector of custom HTML labels for tooltips  | 
Value
A leaflet map object
Create Default Color Matrix for Bivariate Choropleth
Description
Creates a 3x3 color matrix with default colors for bivariate choropleth maps
Usage
create_default_color_matrix()
Value
A matrix of color hex codes
Washington DC Census Tract Data
Description
A dataset containing population and median household income for DC census tracts from ACS 2020. This dataset includes spatial information for creating choropleth maps.
Usage
dc_data()
Format
An sf object with the following variables:
- GEOID
 Census tract identifier
- NAME
 Census tract name
- B01003_001
 Total population estimate from ACS
- B19013_001
 Median household income estimate from ACS
- geometry
 sf geometry column containing tract boundaries
Source
U.S. Census Bureau, 2016-2020 American Community Survey 5-Year Estimates, retrieved using tidycensus package
Examples
data(dc_data)
# View the first few rows of non-geometric columns
print(dc_data[1:5, c("GEOID", "B01003_001", "B19013_001")])
# Create a basic map
if (interactive()) {
  map <- create_bivariate_map(
    data = dc_data,
    var_1 = "B01003_001",    # Total population
    var_2 = "B19013_001"     # Median household income
  )
}
Generate Legend HTML
Description
Generate Legend HTML
Usage
generate_legend_html(var_1, var_2, var_1_breaks, var_2_breaks, color_matrix)
Arguments
var_1 | 
 Character string naming first variable  | 
var_2 | 
 Character string naming second variable  | 
var_1_breaks | 
 Numeric vector of breaks for first variable  | 
var_2_breaks | 
 Numeric vector of breaks for second variable  | 
color_matrix | 
 Matrix of colors  | 
Value
HTML string for legend