Last data update: 2014.03.03

R: Merge ICD-9-CM diagnostic and procedure codes
merge_icd9_dx_and_procsR Documentation

Merge ICD-9-CM diagnostic and procedure codes

Description

Merges a dataframe containing ICD-9-CM diagostic codes with a dataframe containing ICD-9 procedure codes Diagnostic codes are prefixed with 'D', while procedure codes are prefixed with 'P'

Usage

merge_icd9_dx_and_procs(dx_df, proc_df, icd9dxvar = "icd9cm",
  icd9pvar = "icd9cm")

Arguments

dx_df

a data frame with at least two columns, specified as idvar and icd9dxvar, where the values are ICD-9 diagnostic codes

proc_df

a data frame with at least two columns, specified as idvar and icd9pvar, where the values are ICD-9 procedure codes

icd9dxvar

name of icd9 diagnostic code column, default "icd9cm"

icd9pvar

name of icd9 procedure code column, default "icd9cm"

Value

a merged dataframe with common columns and "icd9cm"

Examples

cases <- data.frame(id=c(1,2),
                    icd9dxlist=c('162.4,070.30,155.0,401.9','996.52,E878.8,V45.86'), 
                    icd9plist=c('38.16','38.42'))
dx_df <- melt_icd9list(cases, "id", "icd9dxlist")
proc_df <- melt_icd9list(cases, "id", "icd9plist")
merge_icd9_dx_and_procs(dx_df, proc_df)

Results