This should do it
df = as.data.frame(matrix(c(1,123,5,
1,123,6,
1,123,7,
1,456,3,
1,456,3,
1,456,2,
2,123,1,
2,123,5,
2,123,6,
2,456,2,
2,456,4,
2,456,3), ncol = 3, byrow = T))
colnames(df) = c("Week", "App", "Total")
start_date = as.Date.character("2020-12-27")
do.call(rbind, args = by(df, df[, c("App")], FUN = function(d) {
d$Date = start_date + 1:nrow(d)
d
}))
But it is not taking into acount Week
Could you tell what is expected on a less repetitive dataset
Will there be exactly only a single day between each Date for the same App ?
If not what dictate this ?
e.g.:
df = as.data.frame(matrix(c(1,123,5,
1,123,6,
1,123,7,
1,456,3,
1,456,3,
2,123,1,
2,123,5,
2,123,6,
2,456,2,
2,456,4,
2,456,3,
3,123,4,
3,123,5,
4,123,3,
4,123,3,
4,456,3,
4,456,2), ncol = 3, byrow = T))