The goal is to take a series of event objects and combine them
into a single data set that can be passed to data_set().
as_data_set(x, ...)
# S4 method for ev
as_data_set(x, ...)
# S4 method for data.frame
as_data_set(x, ...)ev objects
more ev objects
A data frame suitable for passing into data_set().
Each event object is added to the data frame as an ID or set of IDs
that are distinct from the IDs in the other event objects. Note that
including ID argument to the ev() call where length(ID) is greater
than one will render that set of events for all of IDs that are requested.
When determining the case for output names, the case attribute for
the first ev object passed will be used to set the case for the output
data.frame.
To get a data frame with one row (event) per ID, look at expand.ev().
a <- ev(amt = c(100,200), cmt=1, ID = seq(3))
b <- ev(amt = 300, time = 24, ID = seq(2))
c <- ev(amt = 1000, ii = 8, addl = 10, ID = seq(3))
as_data_set(a, b, c)
#> ID time cmt evid amt ii addl
#> 1 1 0 1 1 100 0 0
#> 2 1 0 1 1 200 0 0
#> 3 2 0 1 1 100 0 0
#> 4 2 0 1 1 200 0 0
#> 5 3 0 1 1 100 0 0
#> 6 3 0 1 1 200 0 0
#> 7 4 24 1 1 300 0 0
#> 8 5 24 1 1 300 0 0
#> 9 6 0 1 1 1000 8 10
#> 10 7 0 1 1 1000 8 10
#> 11 8 0 1 1 1000 8 10
d <- evd(amt = 500)
as_data_set(d, a)
#> ID TIME CMT EVID AMT
#> 1 1 0 1 1 500
#> 2 2 0 1 1 100
#> 3 2 0 1 1 200
#> 4 3 0 1 1 100
#> 5 3 0 1 1 200
#> 6 4 0 1 1 100
#> 7 4 0 1 1 200
# Instead of this, use expand.ev
as_data_set(ev(amt = 100), ev(amt = 200), ev(amt = 300))
#> ID time cmt evid amt
#> 1 1 0 1 1 100
#> 2 2 0 1 1 200
#> 3 3 0 1 1 300