simcausal (version 0.2.0)

DF.to.longDT: Convert Data from Wide to Long Format Using dcast.data.table

Description

This utility function takes a simulated data.frame in wide format as an input and converts it into a long format using data.table package functions melt.data.table and dcast.data.table.

Usage

DF.to.longDT(df_wide)

Arguments

df_wide
A data.frame in wide format

Value

  • A data.table object in long format

Details

Keeps all covariates that appear only once and at the first time-point constant (carry-forward).

All covariates that appear fewer than range(t) times are imputed with NA for missing time-points.

Observations with all NA's for all time-varying covariates are removed.

When removing NA's the time-varying covariates that are attributes (attnames) are not considered.

See Also

Other data.manipulation.functions: DF.to.long; doLTCF