I have an initial survey (demongraphic,code as time 0) and 10 days of diary survey (time 1 - time 10) data. I am trying to merge initial data and diary data together and then add a column to give the time sequence for each participants. For example, I want to code 0 (under the Time column) for each participant in the initial survey. Then code 1 for the first daily survey, 2 for the second daily survey, and so on.
I tried to merge initial data (df1) and repeated diary data (daily) and name it as Total. Then I added the time column as the following:
Total=merge(df1, daily,by="ID", all=F)
Total$time <- ave(seq_along(Total$ID), Total$ID, FUN = function(x) x - min(x))
But it does not seem right because the constructs in the initial survey is different from the daily survey. Is there other ways to do it? Thank you!