Ok, so here is the problem.
I have a dataset that lists the activity (of various types) associated with various ID's at various times. The dataset is actually a few tens of thousands of rows long and looks like this
ID DATE_EVENT TIME_EVENT EVENT_TYPE
1: 520424473 07/08/2014 09:28:16 9,210
2: 504344215 07/08/2014 09:10:27 1,000
3: 051745297 07/08/2014 09:40:16 1,000
4: 961837100 07/08/2014 09:44:13 1,000
5: 412980113 07/08/2014 09:40:59 1,000
6: 051745297 07/08/2014 09:40:23 9,034
7: 520424473 07/08/2014 09:28:22 1,000
What I would like to be able to do is to to group up things by ID, then order them chronologically and then do statistics on how long was spent in each EVENT_TYPE across the whole data set, (or even better in a range of EVENT_TYPES). I have used this before
library(data.table)
setDT(Allvol)[, list(mean = mean(volume, na.rm = T),
sd = sd(volume, na.rm = T)), by = ID]
on some data previously in order to group data by the ID and then work out the mean and s.d for each one, however that dataset was slightly different and I had a column for volumes associated with EVENT_TYPES. I think I need something similar but am not sure how to approach this.
Any help is much appreciated!