multiple_state_processor: Multiple states

Description Usage Arguments Value Examples

View source: R/multiple_states.R

Description

Sometimes, diseases may have multiple states, for example a different stage of cancer or kidney disease. This function processes comorbid_columns that have multiple states and processes them to a new master_str which is made up of 0s and 1s only. The intended use is to run this on data that has multiple states, merge the master_str to the original data on the basis of the comorbid_column. The make_stem can then be run on this data.

Usage

1
multiple_state_processor(comorbid_column, dis_names = NULL)

Arguments

comorbid_column

A vector of character strings made up of numbers 0-9 or of factors coercible to character, all should be identical lengths.

dis_names

A list of disease names associated with each position as used in get_disease_counts

Value

If dis_names is passed, then a list, the first element of which is a data.frame, the second is a vector of new names. If only comorbid_column is passed, then only a data.frame is returned which includes:

comorbid_column

The original comorbid_column passed to the function

Freq

The frequency of that comorbid_column

master_str

The new string that has been returned

Examples

1
2
3
4
5
comorbid_column <- c('23001', '11101', '21011', '22111', '23001')
disease_names = c('first', 'second', 'third', 'fourth', 'fifth')

ms <- multiple_state_processor(comorbid_column) #no names
ms <- multiple_state_processor(comorbid_column, dis_names = disease_names)

AJFOWLER/comorbidgroupr documentation built on April 8, 2021, 3:51 a.m.