Is there any loops for the mentioned below code?
library(lubridate)
Val_Date <- as.Date("2022-01-1", format = "%Y-%m-%d")
Inception_Date <- as.Date("2012-01-01", format = "%Y-%m-%d")
a <- data.frame(Date = seq(Inception_Date, Val_Date, by = "years"))
b <- data.frame(Date = seq(Inception_Date + years(1), Val_Date, by = "years"))
c <- data.frame(Date = seq(Inception_Date + years(2), Val_Date, by = "years"))
d <- data.frame(Date = seq(Inception_Date + years(3), Val_Date, by = "years"))
e <- data.frame(Date = seq(Inception_Date + years(4), Val_Date, by = "years"))
f <- data.frame(Date = seq(Inception_Date + years(5), Val_Date, by = "years"))
g <- data.frame(Date = seq(Inception_Date + years(6), Val_Date, by = "years"))
h <- data.frame(Date = seq(Inception_Date + years(7), Val_Date, by = "years"))
i <- data.frame(Date = seq(Inception_Date + years(8), Val_Date, by = "years"))
j <- data.frame(Date = seq(Inception_Date + years(9), Val_Date, by = "years"))
k <- data.frame(Date = seq(Inception_Date + years(10), Val_Date, by = "years"))
complete <- rbind(a, b, c, d, e, f, g, h, i, j, k)
In k
my Inception_Date + year(10)
is equal to val_Date
, so I need loop because every time my val date increases I want add a new line of code.