to.unbalanced: Transform data to the longitudinal unbalanced format

Description Usage Arguments Value Author(s) See Also Examples

View source: R/to.unbalanced.R

Description

Transforms a longitudinal data set in the balanced format to the unbalanced format.

Usage

1
to.unbalanced(data, id.col, times, Y.col, other.col = NA)

Arguments

data

a data frame with longitudinal data in the balanced format. That is, in the format of 'one row per subject'. data, where the patient identifications is.

id.col

a column number, or column name, in the data frame data, where the patient identifier is located.

times

a vector with the unique time points where the patients are observed. This is the study design time points in a balanced data set.

Y.col

a vector of column numbers, or column names, of longitudinal variables, and/or time dependent covariates in the data frame data.

other.col

a vector of column numbers, or column names, of baseline covariates, and/or other subject level data, as for example, survival data. Default does not include other.col.

Value

A data frame with longitudinal data in the unbalanced format. The unbalanced format is considered in this context as the format where each row has data on each subject observation.

Author(s)

Ines Sousa ([email protected])

See Also

to.balanced.

Examples

1
2
3
4
5
6
simul <- data.frame(num = 1:10,
                    Y1.1 = rnorm(10), Y1.2 = rnorm(10),
                    Y2.1 = rnorm(10), Y2.2 = rnorm(10), 
                    age = rnorm(10))
to.unbalanced(simul, id.col = 1, times = c(1, 2), Y.col = 2:5,
              other.col = 6)

Example output

Loading required package: survival
   num time        Y1.1         Y2.1         age
1    1    1 -1.13576510  2.332191577 -0.40743958
2    1    2 -2.15147857  0.512786379 -0.40743958
3    2    1  0.11301165 -0.008489456  1.58626738
4    2    2  1.59437459  0.613557301  1.58626738
5    3    1 -0.38177445  2.104917666 -0.23231542
6    3    2  0.66867758 -1.115283443 -0.23231542
7    4    1 -1.93261701  0.367113973 -0.15839341
8    4    2  1.22535061  0.186775413 -0.15839341
9    5    1 -0.31659996 -0.406713324  0.05471483
10   5    2  1.17824270 -0.874101475  0.05471483
11   6    1  0.40684668 -0.464521777  0.12954559
12   6    2 -0.29349469 -0.800635027  0.12954559
13   7    1 -0.74206134 -2.283052516  0.66456947
14   7    2 -0.04004566  1.005260901  0.66456947
15   8    1 -0.30538649 -0.787758548  1.88335280
16   8    2 -1.27448420 -1.274537750  1.88335280
17   9    1 -0.16948833  0.725502765  0.44677821
18   9    2  0.39547466 -0.801378304  0.44677821
19  10    1  0.36790674  0.814383147  0.10509836
20  10    2  1.41097038  0.057664008  0.10509836

joineR documentation built on May 1, 2019, 8:19 p.m.