I'm starting with a dataset that has a numeric column (time in my case, but in numeric format), a certain event for the timestamp, and an ID. I'm hoping to run some code that expands the data frame to fill in the sequence of numbers while duplicating the event column (and any other associated columns). I'd like to run this by ID so I'm not also filling in the gaps between IDs.
Here's a simplified example of the data I'm starting with. I'd like to fill the sequence of the "value" column for each ID separately, completing each new row with the data from the first row for each "event".
a<-c("162", "164", "169", "171", "174", "188", "191", "198","200")
b<-c("start1","end1","start2", "event", "end2", "start1", "end1", "start2", "end2")
c<-c("A","A","A", "A", "A", "B", "B", "B", "B")
original<-data.table(value = a, event = b, ID = c)
And this is a reconstruction of my end goal:
agoal<-c(seq(from = 162, to = 174), seq(from = 188, to = 200))
bgoal<-c("start1","start1","end1","end1", "end1", "end1", "end1",
"start2", "start2", "event", "end2","end2", "end2",
"start1", "start1", "start1", "end1", "end1", "end1", "end1", "end1", "end1", "end1",
"start2", "start2","end2")
cgoal<-c(rep("A",13), rep("B",13))
goal<-data.table(value = agoal, event = bgoal, ID = cgoal)
Sorry if this isn't very clear!