I've got 3 training sets having 5 different events:
list(c('e1','e3','e4'),c('e2','e4'),c('e1','e3','e5'))
I don't know how many events will be there in my list. So I need to count them also. Here I have shown e1 to e5 events as an example. There can be m number of events where I need to find m also. How to find m? In general, how to create m-by-n binary matrix in R where m-total number of events, n-number of training sets? event-IDs might be random, not necessarily of 'eN' type like 'MX050331','IIF02002' etc.
# per the OP's second edit
# now assumes there are no events that haven't been observed at least once
tr <- list(c('e1','e3','e4'),c('e2','e4'),c('e1','e3','e5'))
e <- unique(unlist(tr))
sapply(tr, function(x) e %in% x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With