runs: DREAM run length encoding

Description Usage Arguments Value

Description

Computes the length, values, start, and end, of runs of equal values in a DREAM dataset.

Usage

1
runs(data, row, period = NULL)

Arguments

data

A data.frame (or data.table) containing a DREAM dataset.

row

An integer valued row number (1 to nrow(data)).

period

A character vector of DREAM weeks (e.g. c("y_1701","y_1702","y_1703",...)). If NULL, the default, all DREAM benefit weeks in data is used.

Value

A list with components:
lengths An integer vector containing the length of each run.
values A integer vector of same length as lengths with the corresponding values.
start A character vector of same length as lengths with start weeks. NA imply that the run start prior to first week in period.
end A character vector of same length as lengths with end weeks. NA imply that the run end after last week in period.


carstennielsen/DREAMtoolsR documentation built on May 13, 2019, 11:32 a.m.