I have a list of values that I want to spread evenly over multiple years in R. I think I'm missing something right in front of me.
I have:
#Create dataframe
df <- data.frame(product=rep(c('A','B')),
QTY = c('45', '90'))
#Check
df
# List Years
years <- c(2022:2027)
I would like to spread the values of each product evenly over the years listed ending with something like
| Product | QTY | Year |
|---|---|---|
| A | 6.4 | 2022 |
| A | 6.4 | 2023 |
| A | 6.4 | 2024 |
| A | 6.4 | 2025 |
| A | 6.4 | 2026 |
| A | 6.4 | 2027 |
| B | 12.9 | 2022 |
| B | 12.9 | 2023 |
| B | 12.9 | 2024 |
| B | 12.9 | 2025 |
| B | 12.9 | 2026 |
| B | 12.9 | 2027 |