Skip to contents

The TimeAtRisk class, encapsulating the id, startWith, startOffset, endWith and endOffset

Value

A TimeAtRisk R6 object describing the TAR start and end anchors plus offsets used to compute person-time.

Details

This class is used to specify a time-at-risk (TAR) definition. A TAR is defined by choosing the start/end date of a cohort to start with (plus an offset), and a start/end date of the cohort to end with (plus an offset).

Note, when serializing with a library such as jsonlite, first call toList() on the R6 class before calling jsonlite::toJSON().

Active bindings

id

an integer uniquely identifying this time at risk

startWith

the cohort date to start the time-at-risk. Can be either "start" or "end".

startOffset

The number of days added to the date specified in startWith.

endWith

the cohort date to start the time-at-risk. Can be either "start" or "end".

endOffset

The number of days added to the date specified in startWith.

Methods


TimeAtRisk$new()

creates a new instance, using the provided data param if provided. The JSON takes the form:{"id":1,"start":{"dateField":"start","offset":1},"end":{"dateField":"start","offset":30}}

Usage

TimeAtRisk$new(data = list())

Arguments

data

the data (as a json string or list) to initialize with

Returns

A new TimeAtRisk object initialized from a list or JSON string.


TimeAtRisk$toList()

returns the R6 class elements as a list for use in jsonlite::toJSON()

Usage

TimeAtRisk$toList()

Returns

A named list with id, start, and end fields, where start and end are nested lists containing dateField and offset.


TimeAtRisk$asJSON()

returns the JSON string for this R6 class

Usage

TimeAtRisk$asJSON()

Returns

A JSON string representation of the TimeAtRisk object.


TimeAtRisk$clone()

The objects of this class are cloneable with this method.

Usage

TimeAtRisk$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.