Here is a sample of my dataframe:
df3 <- data.frame(Frame = c(219388, 219389, 219390, 211387, 211388, 211389), Time = c("2020-06-05 13:26:39", "2020-06-05 13:26:39", "2020-06-05 13:26:39", "2020-06-05 13:26:39", "2020-06-05 13:26:39", "2020-06-05 13:26:39"),task = c("hop", "hop", "hop", "vj", "vj", "vj"), limb = c("L", "L", "L", "R", "R", "R"), trial = c("trial1", "trial1", "trial1", "trial2", "trial2", "trial2"))
I want to add NA's to specific rows in the Frame and Time column (amount of NA rows to be added will vary in my real dataset). I also need to continue the task, limb, and trial column accordingly (i.e. hop, L, trial1 continues even on NA rows). My expected output to look like this:
> df3
Frame Time task limb trial
219388 2020-06-05 13:26:39 hop L trial1
219389 2020-06-05 13:26:39 hop L trial1
219390 2020-06-05 13:26:39 hop L trial1
NA NA hop L trial1
NA NA hop L trial1
NA NA hop L trial1
211387 2020-06-05 13:26:39 vj R trial2
211388 2020-06-05 13:26:39 vj R trial2
211389 2020-06-05 13:26:39 vj R trial2
NA NA vj R trial2
NA NA vj R trial2
I've tried insertRows from the berryFunctions package, however this changes the whole row to NA and I need task, limb, and trial columns to continue.
insertRows(df3, r=c(3:5), new=NA, rcurrent=FALSE)
Any help or suggestions would be much appreciated, thank you!