facFlags: Group patients across multiple columns

Description Usage Arguments Author(s) See Also Examples

View source: R/hospCodesFns.R

Description

Group patients against specified groupings using change in factor labels, over all groups.

Usage

1
facFlags(lookup, scheme, data)

Arguments

lookup

Look-up table of codes by group.

scheme

Denotes which type of codes to use e.g. ICD10 or OPCS.

data

Patient data on which to apply the grouping.

Author(s)

N Green

See Also

my_recode, ~~~

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (lookup, scheme, data) 
{
    lookup.list <- as.list(unstack(lookup[lookup$Scheme == scheme, 
        c("Code", "Group")], Code ~ Group))
    y <- apply(data, 2, function(x) my_recode(x, lookup.list))
    list.names <- names(lookup.list)
    res <- NULL
    for (i in list.names) {
        res <- cbind(res, apply(y, 1, function(x) any(x == i)))
    }
    colnames(res) <- list.names
    res
  }

n8thangreen/HESmanip documentation built on March 21, 2020, 12:20 a.m.