Cast one-row-per-clone data to long format

cast_clones_to_long(df)

Arguments

df

A data.frame with one row per clone as returned by create_clones()

Value

A data.frame with one row per patient per time period per clone.

References

Maringe, Camille, et al. "Reflection on modern methods: trial emulation in the presence of immortal-time bias. Assessing the benefit of major surgery for elderly lung cancer patients using observational data." International journal of epidemiology 49.5 (2020): 1719-1729.

Examples


# Load the toy dataset
data(toy_df)

# Create clones
clones <- create_clones(toy_df, 
                        id = "id", 
                        event = "death", 
                        time_to_event = "fup_obs", 
                        exposure = "surgery", 
                        time_to_exposure = "timetosurgery", 
                        ced_window = 365.25/2)

clones_long <- cast_clones_to_long(clones)