I have a very basic question. I have following sample dataframe with two columns; "Date", and "Value":
df <- structure(list(Date = structure(c(17075, 17083), class = "Date"), Value = c(0.16, 0.17)), row.names = c(NA, 2L), class = "data.frame")
I want to create a new dataframe with repeated values around a particular date. Dates should not be repeated but change according to number of steps taken to repeat values.
For example, for above dataframe, if I want a repeat of +-3 steps around the date then output dataframe should be as below:
out <- structure(list(Date = structure(c(17072,17073,17074,17075,17076,17077,17078,17080,17081,17082,17083,17084,17085,17086 , class = "Date"), Value = c(0.16,0.16,0.16,0.16,0.16,0.16,0.16,0.17,0.17,0.17,0.17,0.17,0.17, 0.17)), row.names = c(NA, 14L), class = "data.frame")
How can we do this task? I tried using rep function but didn't work for me.