rmDuplicates: Remove duplicate patient records

Description Usage Arguments Author(s) See Also Examples

View source: R/removeFns.R

Description

Remove patient records for the same patient-stay where one or more of the records have duplicate or missing entries.

Usage

1
rmDuplicates(total.data, subrows)

Arguments

total.data

Complete combined patient record data set.

subrows

Row names of subset of patient records on which to apply function.

Author(s)

N Green

See Also

findDuplicates

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
##---- 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 (total.data, subrows) 
{
    inc.ind <- hos.ind <- rep(TRUE, nrow(total.data))
    inc.ind[subrows] <- total.data$hes_dischargeddeadoralive[subrows] %in% 
        c("Death", "Live")
    hos.ind[subrows] <- total.data$hes_dismethdescription[subrows] %in% 
        c("Not applicable patient still in hospital", "Not known")
    if (any(inc.ind[subrows])) {
        total.data <- rmAllButOne(inc.ind, subrows, total.data)
    }
    else if (all(hos.ind[subrows])) {
        if (any(!is.na(total.data$hes_disdte[subrows]))) {
            hos.ind[subrows] <- total.data$hes_disdt[subrows] == 
                max(total.data$hes_disdte[subrows], na.rm = TRUE)
        }
        total.data <- rmAllButOne(hos.ind, subrows, total.data)
    }
    total.data
  }

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