reform_dates: Reformat dates from long to wide.

Description Usage Arguments Details Value Examples

View source: R/reform_dates.R

Description

This is, broadly speaking a helper function, that turns the txvis object from a long table to a wide table with rows for each patient and columns for regular intervals of dates from a defined start and end along a regular interval. In cases where treatments overlap within a time bin there are three coded conflict resolution methods: (1) majority in which coding priority is given to the treatment that occupies the most time within the interval (2) first in which coding priority is given to the treatment that occurs first chronologically within the interval (3) last in which coding priority is given to the treatment that occurs last chronologically within the interval

Usage

1
2
reform_dates(x, nsequ = NULL, start = NULL, end = NULL,
  interval = "month", conflict = "majority")

Arguments

x

A txvis object

nsequ

The number of drug treatment sequences to use (default is NULL)

start

The starting period for the date matrix. Default is the earliest date in the txvis object.

end

The ending period for the date matrix. Default is the earliest date in the txvis object.

interval

The length of the interval in text format. See Details.

conflict

Conflict resolution.

Details

The interval argument accepts a range of terms

Value

A data.frame.

Examples

1
2
3
4
5
6
7
 hlth_data <- create_txvis(patient   = treat$pat_id, 
                           treatment = treat$treatment,
                           start     = treat$start,
                           end       = treat$end,
                           date_format = "%d%B%Y")
                           
 wide <- reform_dates(hlth_data)

johnwilsonICON/txvis documentation built on May 19, 2019, 5:18 p.m.