Package {adarvmapsr}


Title: Interactive Epidemiological Spot Maps for India
Version: 0.1.20
Description: Build interactive spot maps for epidemiological case-control data in India. Supports automatic detection of latitude, longitude, and outcome columns, spatial joining with bundled state and district boundaries, and produces interactive 'HTML' maps with dot-density and spot-pin display modes. The bundled India state and district boundaries are sourced from the Survey of India and used under the Government Open Data License - India (GODL-India, https://data.gov.in/government-open-data-license-india).
License: MIT + file LICENSE
URL: https://github.com/ADARV-Epi-hub/adarvmapsr
BugReports: https://github.com/ADARV-Epi-hub/adarvmapsr/issues
Encoding: UTF-8
Depends: R (≥ 4.1.0)
Imports: sf, leaflet, htmltools, htmlwidgets, readr, readxl, stats, utils
Suggests: testthat (≥ 3.0.0), knitr, rmarkdown
Config/testthat/edition: 3
Config/roxygen2/version: 8.0.0
NeedsCompilation: no
Packaged: 2026-11-04 04:39:02 UTC; Muniraj Mallesan
Author: Muniraj Mallesan [aut, cre], Sharan Murali [aut], Manikandan K [ctb], Shanmuga Sundharam P [ctb], Yogita Chaudhary [ctb], Barath U [ctb], Balaji S [ctb], Deepana R [ctb]
Maintainer: Muniraj Mallesan <adarv@nieicmr.org.in>
Repository: CRAN
Date/Publication: 2026-11-25 08:50:02 UTC

Internal: save the widget or return it

Description

Internal: save the widget or return it

Usage

.adarvmapsr_finish(m, output)

Build an interactive epidemiological spot map for India

Description

Build an interactive epidemiological spot map for India

Usage

adarvmapsr(
  data,
  state_shp = NULL,
  district_shp = NULL,
  lat_col = NULL,
  lon_col = NULL,
  outcome_col = NULL,
  case_value = NULL,
  all_cases = FALSE,
  count_cutoff = 2L,
  margin_deg = 1,
  cluster_color = "#E85252",
  case_color = "#D55757",
  control_color = "#7676E7",
  case_label = NULL,
  control_label = NULL,
  output = NULL
)

adarvmaps(...)

Arguments

data

Path to a CSV/Excel/TSV file, or a data.frame.

state_shp

Optional custom state boundary file path.

district_shp

Optional custom district boundary file path.

lat_col

Latitude column name. Auto-detected when NULL.

lon_col

Longitude column name. Auto-detected when NULL.

outcome_col

Outcome column name. Auto-detected when NULL.

case_value

Value representing a case. Auto-detected when NULL.

all_cases

If TRUE, skip outcome detection and treat every row as a case (no controls on the map). Useful for outbreak surveillance or case-only datasets that don't have a control group. Defaults to FALSE.

count_cutoff

District count threshold for zoom level (default 2).

margin_deg

Padding in degrees around bounding box (default 1.0).

cluster_color

Hex colour for dot-density clusters.

case_color

Hex colour for case pins.

control_color

Hex colour for control pins.

case_label

Word shown for the main group on the map (legend, pop-ups, menu). Defaults to the actual value from the grouping column (e.g. "Dead"). Pass a string only to override.

control_label

Word shown for the other group. Defaults to the other value in the grouping column when there is exactly one (e.g. "Alive"), otherwise "Others". Pass a string only to override.

output

Path to save the HTML file. If NULL, returns the leaflet widget.

...

Arguments passed on to adarvmapsr() (used by the adarvmaps() alias).

Value

A leaflet widget (invisibly if saved to file).

Examples

## Not run: 
adarvmapsr("cases.csv", output = "map.html")

# Or with a data.frame
adarvmapsr(my_df, lat_col = "lat", lon_col = "lon",
         outcome_col = "status", case_value = "case")

## End(Not run)

Build an outline of India from state boundaries

Description

Build an outline of India from state boundaries

Usage

build_india_outline(states)

Build the top toolbar HTML/CSS for the AdarvMaps (ADARV attached-bar layout)

Description

Build the top toolbar HTML/CSS for the AdarvMaps (ADARV attached-bar layout)

Usage

build_sidebar_html(
  n_cases,
  n_controls,
  mode,
  cluster_color,
  case_color,
  control_color,
  case_label = "Case",
  control_label = "Control"
)

Build the toolbar JavaScript for layer toggling

Description

Build the toolbar JavaScript for layer toggling

Usage

build_sidebar_js(
  cluster_color,
  case_color,
  control_color,
  case_label = "Case",
  control_label = "Control"
)

Crop an sf object to a bounding box with margin

Description

Crop an sf object to a bounding box with margin

Usage

crop_geodataframe(sf_obj, bounds, margin = 1)

Detect latitude and longitude columns

Description

Detect latitude and longitude columns

Usage

detect_lat_lon(df, lat_col = NULL, lon_col = NULL)

Arguments

df

A data.frame.

lat_col

Optional explicit latitude column name.

lon_col

Optional explicit longitude column name.

Value

A named list with elements lat (column name), lon (column name), and df (the data.frame; may have new .adarvmapsr_auto_lat/.adarvmapsr_auto_lon columns appended if a combined column was split).


Detect the outcome column and case value

Description

Detect the outcome column and case value

Usage

detect_outcome(df, outcome_col = NULL, case_value = NULL)

Arguments

df

A data.frame.

outcome_col

Optional explicit outcome column name.

case_value

Optional explicit value that represents a case.

Value

A named list with elements outcome_col and case_value.


Determine map mode: "districts", "states", or "india"

Description

Determine map mode: "districts", "states", or "india"

Usage

determine_mode(
  points_cases,
  district_name_col,
  state_name_col,
  count_cutoff = 2L
)

Load state and district boundary GeoDataFrames

Description

Uses bundled FlatGeobuf files by default. Pass custom paths to override.

Usage

load_boundaries(state_shp = NULL, district_shp = NULL)

Arguments

state_shp

Optional custom state boundary file path.

district_shp

Optional custom district boundary file path.

Value

A named list with states, districts, state_name_col, district_name_col.


Read a data file (CSV, Excel, or TSV) into a data frame

Description

Read a data file (CSV, Excel, or TSV) into a data frame

Usage

load_data(path)

Arguments

path

Path to data file.

Value

A data.frame.


Run an interactive wizard to build a AdarvMaps

Description

Guides users through choosing a data file, selecting columns, and generating the map step by step. Designed for users who prefer a guided experience.

Usage

run_interactive(output_path = .default_output())

Arguments

output_path

Where to save the HTML map. When omitted, defaults to a dated file like "adarvmaps_200926.html".

Value

Invisible NULL.


Spatial join: attach state and district names to each point

Description

Spatial join: attach state and district names to each point

Usage

spatial_join(
  df,
  lat_col,
  lon_col,
  states,
  districts,
  state_name_col,
  district_name_col
)