| read_ccsr | R Documentation |
Reads previously downloaded CCSR mapping files from disk. If no file path is
provided, automatically finds and reads cached files from download_ccsr().
read_ccsr(
file_path = NULL,
type = NULL,
version = "latest",
clean_names = TRUE,
as_data_table = NULL,
name = NULL
)
file_path |
Optional character string, path to a CCSR mapping file. Can be:
|
type |
Character string specifying the type of CCSR file. Must be one
of: "diagnosis" (or "dx") for ICD-10-CM diagnosis codes, or "procedure"
(or "pr") for ICD-10-PCS procedure codes. If NULL and |
version |
Character string specifying the CCSR version to read from cache.
Use "latest" (default) to read the most recent version, or specify a version
like "v2026.1", "v2025.1", etc. Only used when |
clean_names |
Logical. If TRUE (default), column names are cleaned to follow R naming conventions (snake_case). |
as_data_table |
Logical or NULL. If TRUE and the |
name |
Optional character string, suggested variable name for the
returned data. This is only used for display/messaging purposes and does
not automatically assign the data to a variable. You must still assign the
result: |
This function can read CCSR files in several formats:
ZIP files downloaded from HCUP (will extract and read the CSV/Excel file)
CSV files (extracted from ZIP or saved separately)
Excel files (if readxl package is available)
Directories containing extracted files
Cached files from download_ccsr() (automatic if file_path is NULL)
The function automatically detects the file format and handles encoding issues, preserving leading zeros in ICD-10 codes.
When file_path is NULL, the function automatically searches the cache
directory (tempdir()/HCUPtools_cache/) for files matching the specified
type and version. This makes it easy to read previously downloaded
files without needing to know the exact file path.
A tibble (or data.table if as_data_table = TRUE) containing the
CCSR mapping data. Tibbles are data frames and can be used with all
standard R data frame operations, including dplyr, data.table, and
base R functions.
To use the data, assign it to a variable:
my_data <- read_ccsr(). The name parameter is only for display
purposes and does not automatically assign the data.
# Populate cache, then read (requires network)
invisible(download_ccsr("diagnosis"))
dx_map <- read_ccsr(as_data_table = FALSE)
invisible(download_ccsr("procedure"))
pr_map <- read_ccsr(type = "procedure", as_data_table = FALSE)
# From a local file on your machine (uncomment and set the path):
# dx_map <- read_ccsr("/path/to/DXCCSR-v2026-1.zip", as_data_table = FALSE)
# dx_map <- read_ccsr("/path/to/DXCCSR_v2026_1.csv", as_data_table = FALSE)
# dx_map <- read_ccsr("/path/to/extracted_ccsr_files/", as_data_table = FALSE)
head(dx_map)
nrow(dx_map)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.