data(toyll)
toyll
toyll$date.of.onset <- as.POSIXct(toyll$date.of.onset)
toyll$date.of.admission <- as.POSIXct(toyll$date.of.admission)
toyll$date.of.discharge <- as.POSIXct(toyll$date.of.discharge)
toyll$contact1.date <- as.POSIXct(toyll$contact1.date)
toyll$contact2.date <- as.POSIXct(toyll$contact2.date)
toyll$contact3.date <- as.POSIXct(toyll$contact3.date)
ind.fields <- c(names(toyll)[1:5], "hospital", "fever", "sleepy")
x <- as.ejObject(toyll,
recordAttributes=ind.fields,
eventDefinitions=list(
define_ejEvent(name="admission", date="date.of.admission"),
define_ejEvent(name="discharge", date="date.of.discharge"),
define_ejEvent(name="contact1", date="contact1.date", attributes="contact1.id"),
define_ejEvent(name="contact2", date="contact2.date", attributes="contact2.id"),
define_ejEvent(name="contact3", date="contact3.date", attributes="contact3.id")
))
x
Run the code above in your browser using DataLab