sample_diag: Simulate ICD-10 and ICD-9 diagnostic codes

View source: R/sample_diag.R

sample_diagR Documentation

Simulate ICD-10 and ICD-9 diagnostic codes

Description

A simple function to simulate ICD-10 and ICD-9 diagnostic codes at random.

Usage

sample_diag(n = 1, version = "ICD10_2011")

Arguments

n

Number of ICD codes to simulate.

version

The version of the ICD coding scheme to use. Possible choices are ICD10_2009, ICD10_2011, and ICD9_2015; defaults to ICD10_2011. See icd10_2009, icd10_2011, and icd9_2015 for further information on the different schemes.

Value

A vector of n ICD diagnostic codes.

Examples

# Simulate 10 ICD-10 codes
sample_diag(10)

# Simulate a tidy dataset with 15 individuals and 200 rows
set.seed(1)
x <- data.frame(
  id = sample(1:15, size = 200, replace = TRUE),
  code = sample_diag(n = 200),
  stringsAsFactors = FALSE
)
head(x)

ellessenne/comorbidity documentation built on May 4, 2023, 10:36 p.m.