TraMineRextras (version 0.6.0)

FCE_to_TSE: Data conversion from Fixed Column Event format to TSE.

Description

Data conversion from Fixed Column Event format to TSE.

Usage

FCE_to_TSE(seqdata, id = NULL, cols, eventlist = NULL, firstEvent = NULL)

Arguments

seqdata

data frame or matrix containing event sequence data in FCE format.

id

column containing the identification numbers for the sequences.

cols

Real. Column containing the timing of the event. A missing value is interpreted as a non-occurrence of the event.

eventlist

Event names, specified in the same order as cols argument. If NULL (default), column names are used.

firstEvent

Character. The name of an event to be added at the beginning of each event sequences. This allows to include individuals with no events. If NULL (default), no event is added.

Value

A data.frame with three columns: "id", "timestamp" and "event".

Details

The usual data format for event sequence is TSE (see seqecreate).

See Also

seqecreate, seqformat

Examples

Run this code
# NOT RUN {
## Generate a ramdom data set
fce <- data.frame(id=1:100, event1=runif(100), event2=runif(100))

## Add missing values (ie non-occurrences)
fce[runif(100)<0.1, "event1"] <- NA
fce[runif(100)<0.1, "event2"] <- NA

tse <- FCE_to_TSE(fce, id="id", cols=c("event1", "event2"),
       eventlist=c("Marriage", "Child birth"), firstEvent="Birth")

seq <- seqecreate(tse)
print(seq[1:10])

# }

Run the code above in your browser using DataLab