I have a dataset that looks like this:
Date,Open,High,Low,Close,Adjusted_close,Volume
2020-10-28,1384,1384,1384,1384,1384,0
2020-10-29,1297,1297,1297,1297,1297,0
2020-10-30,1283,1283,1283,1283,1283,0
2020-11-02,1284,1284,1284,1284,1284,0
2020-11-03,1263,1263,1263,1263,1263,0
2020-11-04,1224,1224,1224,1224,1224,0
2020-11-05,1194,1194,1194,1194,1194,0
2020-11-06,1196,1196,1196,1196,1196,0
2020-11-09,1207,1207,1207,1207,1207,0
2020-11-10,1200,1200,1200,1200,1200,0
and I wanted to fill in values for say 10-31 and 11-1 to contain the values from the previous trading day (10-30). How is this easily accomplished in R? I feel as though library(tidyr) and complete fit into this picture somehow?
Expected representation would be:
Date,Open,High,Low,Close,Adjusted_close,Volume
2020-10-28,1384,1384,1384,1384,1384,0
2020-10-29,1297,1297,1297,1297,1297,0
2020-10-30,1283,1283,1283,1283,1283,0
2020-10-31,1283,1283,1283,1283,1283,0
2020-11-01,1283,1283,1283,1283,1283,0
2020-11-02,1284,1284,1284,1284,1284,0
2020-11-03,1263,1263,1263,1263,1263,0
2020-11-04,1224,1224,1224,1224,1224,0
2020-11-05,1194,1194,1194,1194,1194,0
2020-11-06,1196,1196,1196,1196,1196,0
2020-11-07,1196,1196,1196,1196,1196,0
2020-11-08,1196,1196,1196,1196,1196,0
2020-11-09,1207,1207,1207,1207,1207,0
2020-11-10,1200,1200,1200,1200,1200,0
Requested dput output
structure(list(Date = c("2020-10-28", "2020-10-29", "2020-10-30",
"2020-11-02", "2020-11-03", "2020-11-04", "2020-11-05", "2020-11-06",
"2020-11-09", "2020-11-10"), Open = c(1384L, 1297L, 1283L, 1284L,
1263L, 1224L, 1194L, 1196L, 1207L, 1200L), High = c(1384L, 1297L,
1283L, 1284L, 1263L, 1224L, 1194L, 1196L, 1207L, 1200L), Low = c(1384L,
1297L, 1283L, 1284L, 1263L, 1224L, 1194L, 1196L, 1207L, 1200L
), Close = c(1384L, 1297L, 1283L, 1284L, 1263L, 1224L, 1194L,
1196L, 1207L, 1200L), Adjusted_close = c(1384L, 1297L, 1283L,
1284L, 1263L, 1224L, 1194L, 1196L, 1207L, 1200L), Volume = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), row.names = c(NA, 10L), class = "data.frame")