I have a behavioral ethogram dataframe which has Observation ID (file numbers 1-112), Behavior, Behavior type (point/ state event) and time of occurrence (values from 0 to 60 seconds) see below
I would like to create a new data frame where I have a separate column for time value from 0 to 60 (secs). Each observation ID should have a corresponding time value which runs from 0 to 60. All the behaviors are arranged in separate columns. If a behavior occurs within a time value according to time of occurrence it should get a score of 1 if not then 0. State events should get a score of 1 when first observed until last observed. See sample below
I have managed to use the spread function to create separate columns for behavior New_df <- spread(df,key = Behavior, value = Time.converted)
However I am encountering problems when I try to assign each file number with values from 0 to 60. Any direction with regard to what functions to use or code would be appreciated.