wideToLongTDC: Function from wide to long format

Description Usage Arguments Value References See Also Examples

Description

Function from wide to long format

Usage

1
2
wideToLongTDC(data, id, tstart, tstop, event, bas.cov, mes.cov, time.cov,
  times)

Arguments

data

a dataframe containing the variables id, tstart, tstop, mes.cov and time.cov

id

the patient's id

tstart

date of the beginning of the follow-up (in Date format)

tstop

date of the end of the follow-up (in Date format)

event

the indicator of failure (a death is denoted by 1 at the end of the follow-up)

bas.cov

a vector containing the names (in character format) of the baseline covariates

mes.cov

a list of vectors, each of them must contain the names (in character format) of the repeated measurements related to one time-dependent covariate

time.cov

a list of vectors, each of them must contain the times (in Date format) of the date when the abovementioned measurements were done

times

a list of vectors. Each of them must contain, for each patient, the event time and the times of changes in time-varying covariates

Value

the long format version of the initial dataframe data. The repeated values included in each vector of the list mes.cov are aggregated in a variable named aas the name of the corresponding list member.

References

Graffeo, N., Latouche, A., Le Tourneau C., Chevret, S. "An R Package for IPCW: Application to switches in clinical trials" (submitted)

See Also

SHIdat, timesTokeep

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# To obtain the times parameter, we can apply the timesTokeep function on the same
# dataframe in the wide format
kept.t <- timesTokeep(toydata, id = "id",
tstart = "randt", tstop = "lastdt",
mes.cov = list(c("ps1", "ps2", "ps3")),
time.cov = list(c("randt", "dt2", "dt3")))
# Now, we can build the long format
toy.long <- wideToLongTDC(data = toydata, id = "id",
tstart = "randt", tstop = "lastdt", event = "status",
bas.cov = c("age", "arm", "swtrtdt"),
mes.cov = list(TDconf = c("ps1", "ps2", "ps3")),
time.cov = list(c("randt", "dt2", "dt3")),
times = kept.t[[1]])
toy.long

ipcwswitch documentation built on May 16, 2019, 1:12 a.m.