Learn R Programming

CodelistGenerator (version 4.0.0)

compareCodelists: Compare overlap between two sets of codes

Description

Compare overlap between two sets of codes

Usage

compareCodelists(codelist1, codelist2)

Value

Tibble with information on the overlap of codes in both codelists.

Arguments

codelist1

Output of getCandidateCodes or a codelist

codelist2

Output of getCandidateCodes.

Examples

Run this code
# \donttest{
library(CodelistGenerator)
library(omock)

# Create a CDM object
downloadMockDataset(datasetName = "GiBleed",
                    path = NULL,
                    overwrite = NULL)
cdm <- mockCdmFromDataset(datasetName = "GiBleed")

# Compare two candidate_codes object
codes1 <- getCandidateCodes(
  cdm = cdm,
  keywords = "Arthritis",
  domains = "Condition",
  includeDescendants = TRUE)

codes2 <- getCandidateCodes(
  cdm = cdm,
  keywords = c("osteo"),
  domains = "Condition",
  includeDescendants = TRUE)

compareCodelists(
  codelist1 = codes1,
  codelist2 = codes2)

# Compare two codelists
acetaminophen <- getDrugIngredientCodes(cdm,
                                        name = "acetaminophen",
                                        nameStyle = "{concept_name}",
                                        type = "codelist")

hydrocodone <- getDrugIngredientCodes(cdm,
                                      name = "hydrocodone",
                                      nameStyle = "{concept_name}",
                                      type = "codelist")
compareCodelists(
  codelist1 = acetaminophen,
  codelist2 = hydrocodone)
# Notice that concept_name = NA as `codelist` class does not store this information
# for each concept.

# Compare two codelists_with_details
acetaminophen <- getDrugIngredientCodes(cdm,
                                        name = "acetaminophen",
                                        nameStyle = "{concept_name}",
                                        type = "codelist_with_details")

hydrocodone <- getDrugIngredientCodes(cdm,
                                      name = "hydrocodone",
                                      nameStyle = "{concept_name}",
                                      type = "codelist_with_details")
compareCodelists(
  codelist1 = acetaminophen,
  codelist2 = hydrocodone)

# }

Run the code above in your browser using DataLab