Package 'covid19india'

Title: Pulling Clean Data from Covid19india.org
Description: Pull raw and pre-cleaned versions of national and state-level COVID-19 time-series data from covid19india.org <https://www.covid19india.org>. Easily obtain and merge case count data, testing data, and vaccine data. Also assists in calculating the time-varying effective reproduction number with sensible parameters for COVID-19.
Authors: Max Salvatore [aut, cre], Michael Kleinsasser [aut]
Maintainer: Max Salvatore <[email protected]>
License: MIT + file LICENSE
Version: 0.1.5
Built: 2025-03-08 03:00:52 UTC
Source: https://github.com/maxsal/covid19india

Help Index


Check for data corrections of X-times magnitude - data.table style

Description

Check for data corrections of X-times magnitude - data.table style

Usage

check_for_data_correction(
  dat,
  var,
  magnitude = 10,
  min_count = 10,
  fill_locf = TRUE
)

Arguments

dat

data set

var

variable for which to check for corrections. Default is "daily_cases"

magnitude

magnitude of difference that qualifies as a data correction. Default is 10.

min_count

minimum count of var. Default is 10.

Value

Data set with data correction observations removed

Examples

## Not run: 
check_for_data_correction(dat = get_nat_counts, var = "daily_cases", magnitude = 10)

## End(Not run)

Helper function

Description

Helper function

Usage

extract_latest(dat, group = place, clmns = c("total_tests", "tpr", "ppt"))

Arguments

dat

data set

group

place variable

clmns

columns to be extracted

Value

Data set of recent observations of selected variables

Examples

## Not run: 
extract_latest(dat = get_all_data())

## End(Not run)

Pull all covid19india count, test, and vaccine data for states and nation

Description

Pull all covid19india count, test, and vaccine data for states and nation

Usage

get_all_data(
  keep_nat = TRUE,
  covind19_name_scheme = FALSE,
  corr_check = TRUE,
  mohfw = TRUE,
  inc_days = 3
)

Arguments

keep_nat

Keep the national data as well. Default is FALSE

covind19_name_scheme

Variable naming scheme used for development of covind19.org application

corr_check

Check for data corrections of X-times magnitude. Default is TRUE

mohfw

mohfw switch to mohfw. Defauly is FALSE - will default to TRUE in future

inc_days

Number of days from infection to symptoms

Value

Pulls the district-level time-series case, death, and recovered data directly from covid19india.org.

Examples

## Not run: 
get_all_data()

## End(Not run)

Calculate case_fataility rate

Description

Calculate case_fataility rate

Usage

get_cfr(x)

Arguments

x

Input dataset. Expects total_cases and total_deaths variables

Value

Calculates a case-fatality rate estimate and corresponding 95% confidence interval

Examples

## Not run: 
get_cfr(x = get_nat_counts())

## End(Not run)

Pull covid19india district-level data

Description

Pull covid19india district-level data

Usage

get_district_counts(
  path = "https://api.covid19india.org/csv/latest/districts.csv",
  raw = FALSE
)

Arguments

path

The URL path for the data. Default: ⁠https://api.covid19india.org/csv/latest/districts.csv⁠

raw

Pull raw unaltered data. Default is FALSE

Value

Pulls the district-level time-series case, death, and recovered data directly from covid19india.org.

Examples

## Not run: 
get_district_counts()

## End(Not run)

Create metrics tables

Description

Create metrics tables

Usage

get_metrics_tables(
  seed = 46342,
  top20 = NULL,
  corr_check = FALSE,
  inc_days = 3
)

Arguments

seed

set seed

top20

Vector of state abbreviations for top 20 table

corr_check

Check for data corrections of X-times magnitude. Default is TRUE

inc_days

Number of days from infection to symptoms

Value

Creates metrics tables for use in covind19.org

Examples

## Not run: 
tabs   <- get_metrics_tables()

tabs$full

## End(Not run)

Pull covid19india national time series data

Description

Pull covid19india national time series data

Usage

get_nat_counts(
  path = "https://api.covid19india.org/csv/latest/case_time_series.csv",
  raw = FALSE,
  corr_check = TRUE,
  mohfw = TRUE
)

Arguments

path

The URL path for the data. Default: https://api.covid19india.org/csv/latest/case_time_series.csv

raw

Pull raw unaltered data. Default is FALSE

corr_check

Check for data correction. Default is FALSE

mohfw

switch to mohfw default is TRUE

Value

Pulls the time-series case, death, and recovered data directly from covid19india.org.

Examples

## Not run: 
get_nat_counts_dt()

## End(Not run)

Pull covid19india national time series test data

Description

Pull covid19india national time series test data

Usage

get_nat_tests(
  path = "https://data.covid19india.org/csv/latest/tested_numbers_icmr_data.csv",
  raw = FALSE
)

Arguments

path

The URL path for the data. Default: ⁠https://api.covid19india.org/data.json⁠

raw

Pull raw unaltered data. Default is FALSE

Value

Pulls the time-series test data directly from covid19india.org.

Examples

## Not run: 
get_nat_tests()

## End(Not run)

Helper function for pulling latest R estimates

Description

Helper function for pulling latest R estimates

Usage

get_r_est(x)

Arguments

x

data set containing R estimates

Value

Pulls 7-day trailing average R estimates and 95% confidence intervals

Examples

## Not run: 
get_r_est(x = get_all_data())

## End(Not run)

Calculate r0

Description

Calculate r0

Usage

get_r0(
  dat,
  daily_filter = 0,
  total_filter = 50,
  min_date = "2020-03-23",
  corr_check = FALSE,
  inc_days = 3
)

Arguments

dat

Input dataset. Expects daily_cases, total_cases, and place columns

daily_filter

Threshold for minimum daily cases. Default = 0.

total_filter

Threshold for minimum total cases reported to date. Default = 50.

min_date

Threshold for earliest date to report R_0. Default = "2020-03-23".

corr_check

Check for data corrections of X-times magnitude. Default is FALSE

inc_days

Number of days from infection to symptoms

Value

Pulls the time-series state-level testing data directly from covid19india.org. Expects columns named place, daily_cases, and total_cases. Can specify corresponding variables through other arguments.

Examples

## Not run: 
get_r0(dat = get_nat_counts())

## End(Not run)

Pull covid19india state

Description

Pull covid19india state

Usage

get_state_counts(
  path = "https://api.covid19india.org/csv/latest/state_wise_daily.csv",
  raw = FALSE,
  keep_nat = FALSE,
  corr_check = FALSE,
  mohfw = TRUE
)

Arguments

path

The URL path for the data. Default: ⁠https://api.covid19india.org/csv/latest/state_wise_daily.csv⁠

raw

Pull raw unaltered data. Default is FALSE

keep_nat

Keep the national data as well. Default is FALSE

corr_check

Check for data correction. Default is FALSE

mohfw

switch to mohfw default is TRUE

Value

Pulls the time-series case, death, and recovered data directly from covid19india.org.

Examples

## Not run: 
get_state_counts()

## End(Not run)

Pull covid19india state-level testing data

Description

Pull covid19india state-level testing data

Usage

get_state_tests(
  path = "https://api.covid19india.org/csv/latest/statewise_tested_numbers_data.csv",
  raw = FALSE
)

Arguments

path

The URL path for the data. Default: https://api.covid19india.org/csv/latest/statewise_tested_numbers_data.csv

raw

Pull raw unaltered data. Default is FALSE

Value

Pulls the time-series state-level testing data directly from covid19india.org.

Examples

## Not run: 
get_state_tests()

## End(Not run)

Pull covid19india state-level vaccine data

Description

Pull covid19india state-level vaccine data

Usage

get_state_vax(
  path = "https://api.covid19india.org/csv/latest/vaccine_doses_statewise_v2.csv",
  raw = FALSE,
  keep_nat = TRUE,
  mohfw = TRUE
)

Arguments

path

The URL path for the data. Default: https://api.covid19india.org/csv/latest/vaccine_doses_statewise_v2.csv

raw

Pull raw unaltered data. Default is FALSE

keep_nat

Keep national level data? Default is TRUE

mohfw

switch to mohfw. default is TRUE

Value

Pulls the time-series state-level vaccine data directly from covid19india.org.

Examples

## Not run: 
get_state_vax()

## End(Not run)

List of places, abbreviations, and populations in India

Description

This data set contains the names of states and union territories in India along with their respective abbreviations and populations. The population of India is also given. These are 2019 projections as reported in the Unique Identification Authority of India 2019-2020 Annual Report.

Usage

pop

Format

A data frame with 39 rows and 3 variables: place, abbrev, population

place

The name of the place

abbrev

The abbreviations corresponding to place

population

The population size

References

2019-2020 Annual Report Annexure IV (pg 103), Unique Identification Authority of India https://uidai.gov.in/images/AADHAR_AR_2019_20_ENG_approved.pdf