Here is an example of how to append the Var1 values to DF.
library(tidyverse)
#Manually make the matrix, since you provided only an image
Var1 <- matrix(c(2.500960, 1.982514, -0.500000,
2.547257, 1.974937, 1.700744,
2.492687, -0.500000, -0.500000),
nrow =3, byrow = TRUE,
dimnames = list(c('2021-01-05', '2021-04-05','2021-05-05'),
c('2021-05-15', '2021-06-19', '2021-07-17')))
#Store the start and end dates
Starts <- dimnames(Var1)[[1]]
Ends <- dimnames(Var1)[[2]]
#Make a data frame with the matrix values
Var1_values <- as.vector(Var1)
Var1_DF <- data.frame(t = as.Date(rep(Starts, 3)),
T = as.Date(rep(Ends, each = 3)),
Var1 = Var1_values)
Var1_DF
#> t T Var1
#> 1 2021-01-05 2021-05-15 2.500960
#> 2 2021-04-05 2021-05-15 2.547257
#> 3 2021-05-05 2021-05-15 2.492687
#> 4 2021-01-05 2021-06-19 1.982514
#> 5 2021-04-05 2021-06-19 1.974937
#> 6 2021-05-05 2021-06-19 -0.500000
#> 7 2021-01-05 2021-07-17 -0.500000
#> 8 2021-04-05 2021-07-17 1.700744
#> 9 2021-05-05 2021-07-17 -0.500000
#Make DF
DF <- structure(list(t = structure(c(18632, 18632, 18632, 18632, 18722,
18722, 18722, 18722, 18722, 18722, 18722, 18722, 18722, 18722,
18722, 18722, 18752, 18752, 18752), class = "Date"),
T = structure(c(18762,18762, 18825, 18825, 18762, 18762, 18762, 18762, 18797, 18797,
18825, 18825, 18825, 18825, 18825, 18825, 18762, 18762, 18762), class = "Date"),
P = c(0.307226768393632, 0.301688731220703,
0.397136088790893, 0.383877823336263, 0.236323307903033, 0.233372881698608,
0.231780329830088, 0.23386123036873, 0.387233363333833, 0.383031632908323,
0.363130308318273, 0.362333112682333, 0.339339339130839, 0.336762032999268,
0.333986731161336, 0.33217086638931, 0.306362313368632, 0.300638233383397,
0.303293118713379),
Q = c(0.48332, 0.48332, 0.328632, 0.328632,0.48332, 0.48332, 0.48332, 0.48332, 0.30832, 0.30832, 0.32372,
0.32372, 0.32372, 0.32372, 0.32372, 0.32372, 0.4802, 0.4802,
0.4802)), class = "data.frame", row.names = c(NA, -19L))
#Join the Var1 values to DF
DF <- inner_join(DF, Var1_DF, by = c("T","t"))
Created on 2025-04-18 with reprex v2.1.1