I have multiple, equal-sized dataframes containing different daily values (e.g. yield, bid-ask spread,...) for several financial instruments, which I want to merge into one dataframe. Let's say I have:
X
Date A B C
2020-12-16 XA1 XB1 XC1
2020-12-15 XA2 XB2 XC2
2020-12-14 XA3 XB2 XC3
...
and:
Y
Date A B C
2020-12-16 YA1 YB1 YC1
2020-12-15 YA2 YB2 YC2
2020-12-14 YA3 YB2 YC3
...
And I would like to get:
Z
ISIN Date X Y
A 2020-12-16 XA1 YA1
A 2020-12-15 XA2 YA2
A 2020-12-14 XA3 YA3
B 2020-12-16 XB1 YB1
B 2020-12-15 XB2 YB2
B 2020-12-14 XB3 YB3
C 2020-12-16 XC1 YC1
C 2020-12-15 XC2 YC2
C 2020-12-14 XC3 YC3
...
So far I managed to create a dataframe in this simplistic way:
X = c(as.matrix(X[,2:ncol(X)]))
Y = c(as.matrix(Y[,2:ncol(Y)]))
df = data.frame(X,Y)
However, as you can see the results does not include neither the ISIN nor the date. I'm pretty sure there is a logical and efficient solution to solve this problem, which however I didn't figure it out yet. Any help would be much appreciated!