DF.to.longDT: Faster Conversion of Data from Wide to Long Format Using...

View source: R/simulation.r

DF.to.longDTR Documentation

Faster Conversion of Data from Wide to Long Format Using dcast.data.table

Description

Faster utility function for converting wide-format data.frame into a long format. Internally uses data.table package functions melt.data.table and dcast.data.table.

Usage

DF.to.longDT(df_wide, return_DF = TRUE)

Arguments

df_wide

A data.frame or data.table in wide format

return_DF

TRUE (default) to return a data.frame, FALSE returns a data.table

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.

Value

A data.frame in long format

See Also

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


osofr/simcausal documentation built on Oct. 21, 2022, 3:09 a.m.