Description Usage Arguments Note Examples
Convert a dataframe to an ejObject
| 1 2 3 | ## S3 method for class 'data.frame'
as.ejObject(x, recordID = NA, recordAttributes,
  eventDefinitions, metadata = list(), ...)
 | 
| x | The dataframe to convert | 
| recordID | an ID for the record, if NA one is created | 
| recordAttributes | A character vector containing the names of the columns in the dataframe that are attributes of the record | 
| eventDefinitions | A list of event definitions | 
| metadata | A list of metadata ejAttribute objects describing the dataset | 
| ... | other parameters (to maintain consistency with the generic) | 
We assume one row per record.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #Here we use the toyll (toy line-list) data provided inside the package
data(toyll)
toyll
#Here we some data clean-up (make the date columns POSIX objects)
#Date-time conversion could be made automatic but introduces
#a big risk of mis-conversion so we leave this to the user
#to ensure that we don't silently corrupt their data
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")
                 ))
print(x)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.