I'm trying to create hypothetical data for a predictive analysis. I have a set of averages I plan to apply my predictive model to. However, I want to expand my DF with various values in the Agent_Count column. Is there a way to copy columns 2-4 to new rows while changing the value of column 1, in those new rows, to a new hypothetical value. I would like to do this say 20-30 times.
Here is my data.
Group Agent_Count HOUR Answered_Calls Aban Total_Calls
Clinical Support 11.75 9 52.69 2.77 56.65
PW Reset 12.06 9 53.79 22.27 81.98
Technical Support 21.15 9 81.02 2.22 84.20
In base R, you can "extend" the same data frame
ntimes using therepeat()function:You can then replace new rows with new values. For instance, to replace rows 4 and onwards with +1 the previous value:
Or to replace the values with a random number (here, generated form a normal distribution with mean = 11 and sd = 5):