Remove cuts from your tree. This is, e.g., useful if you would like to remove certain chapters from the ICD-10 tree used for the analysis as some chapters might be a prior deemed irrelevant for the exposure of interest, e.g., chapter 20 (external causes of death) might not be of interest when comparing two drug exposures.
drop_cuts(tree, cuts, delimiter = "/", return_removed = FALSE)If return_removed = FALSE a data.frame with a single variable named
pathString is returned, which includes the updated tree. If
return_removed = TRUE a list with two elements is return:
The updated tree file
A list of character vectors including the paths that
have been removed from the supplied tree. The list is named using the
cuts supplied to cut.
A dataset with one variable pathString defining the tree structure
that you would like to use. This dataset can, e.g., be created using
create_tree.
A character vector of cuts to remove. Please make sure that your string
uniquely identifies the cut that should be removed. Each string is passed
to base::gsub() to identify the cuts that should be removed. Hence, strings
can include regular expressions for identifying cuts. If you would like to
remove a cut on the top level of the hierarchy, it might be helpful to use
the regular expression operator ^.
Regular expression are composed as follows:
paste0(cuts, delimiter, "?(.*)")
A character defining the delimiter of different tree levels within your
pathString. The default is /.
A logical value for indicating whether you would like to get a list of removed cuts returned by the function.
drop_cuts(icd_10_se, c("B35-B49", "F41")) |>
head()
Run the code above in your browser using DataLab