Learn R Programming

TrialEmulation (version 0.0.4.2)

ipw_data: IPW Data Accessor and Setter

Description

[Experimental]

Usage

ipw_data(object)

ipw_data(object) <- value

# S4 method for trial_sequence ipw_data(object)

# S4 method for trial_sequence ipw_data(object) <- value

Value

The data from the @data slot of object used for inverse probability weighting.

Arguments

object

trial_sequence object

value

data.table to replace and update in @data

Details

Generic function to access and update the data used for inverse probability weighting.

The setter method ipw_data(object) <- value does not perform the same checks and manipulations as set_data(). To completely replace the data please use set_data(). This ipw_data<- method allows small changes such as adding a new column.

Examples

Run this code
ts <- trial_sequence("ITT")
ts <- set_data(ts, data_censored)
ipw_data(ts)
data.table::set(ipw_data(ts), j = "dummy", value = TRUE)

# or with the setter method:
new_data <- ipw_data(ts)
new_data$x2sq <- new_data$x2^2
ipw_data(ts) <- new_data

Run the code above in your browser using DataLab