catStays: Concatenate hospital stays

Description Usage Arguments Examples

View source: R/splitFillCatFns.R

Description

Concatenate same spell records when the patient is moved within hospital i.e. discharge=arrival time

Usage

1
catStays(total.data)

Arguments

total.data

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) 
{
    uniqueid <- unique(total.data$hes_ID)
    progressbar <- txtProgressBar(min = 0, max = length(uniqueid), 
        style = 3)
    counter = 0
    for (i in uniqueid) {
        counter = counter + 1
        setTxtProgressBar(progressbar, counter)
        ind <- which(total.data$hes_ID == i)
        newTimes <- spellLength2(total.data$hes_admdte[ind], 
            total.data$hes_disdte[ind])
        total.data$hes_admdte[ind] <- newTimes$adm
        total.data$hes_disdte[ind] <- newTimes$disch
        total.data$missingTime[ind][is.na(total.data$hes_disdte[ind])] <- 0
    }
    close(progressbar)
    total.data
  }

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