I have something like df1 (time in ms), but then with thousands of rows:
df1 <- data.frame(time=c(105, 202, 305, 408, 505, 608), event=c("", "", "", "onset", "", ""))
What I want to do is, for every instance of "onset", add the variable "start" in the same column and 200ms before that instance of onset. So, it should end up like this in this simplified case:
df2 <- data.frame(time=c(105, 202, 208, 305, 408, 505, 608), event=c("", "", "start", "", "onset", "", ""))
I haven't been able to figure out how to do this, help would be greatly appreciated!